Commits

Kimmo Varis committed cff1d85

Add errortype to the Error.

We can divide errors to real errors and information messages, both
parsed similarly from the Cppcheck results. But we probably want to
show them differently.

Also add parameters to init for easier construction.

Comments (0)

Files changed (1)

 class Error(object):
     '''Error found from the code.'''
     
-    def __init__(self):
-        self.id = ''
-        self.severity = ''
-        self.msg = ''
+    def __init__(self, id='', severity='error', msg='', etype=0):
+        self.id = id
+        self.severity = severity
+        self.msg = msg
         self.verbosemsg = ''
         self.location = []
+        self.etype = etype # 0 error, 1 information
 
     def dump(self):
         '''Print simply formatted error to the console.'''
         errstr += '    {0}\n'.format(self.msg)
         errstr += '    {0}\n'.format(self.verbosemsg)
         print(errstr)
+
+    def getDefaultLocation(self):
+        '''Get the primary location of the error.'''
+
+        if len(self.location) > 0:
+            return self.location[0].filename, self.location[0].lineno
+        else:
+            return '', 0