diff python/ppci/errors.py @ 200:5e391d9a3381

Split off asm nodes
author Windel Bouwman
date Sun, 09 Jun 2013 16:06:49 +0200
parents b01429a5d695
children c1ccb1cb4cef
line wrap: on
line diff
--- a/python/ppci/errors.py	Fri Jun 07 18:59:57 2013 +0200
+++ b/python/ppci/errors.py	Sun Jun 09 16:06:49 2013 +0200
@@ -6,12 +6,16 @@
 from . import SourceLocation
 
 class CompilerError(Exception):
-    def __init__(self, msg, loc):
+    def __init__(self, msg, loc=None):
         self.msg = msg
         self.loc = loc
-        assert type(loc) is SourceLocation, '{0} must be SourceLocation'.format(type(loc))
+        if loc:
+            assert type(loc) is SourceLocation, '{0} must be SourceLocation'.format(type(loc))
     def __repr__(self):
-        return 'Compilererror {0} at row {1}'.format(self.msg, self.loc.row)
+        if self.loc:
+            return 'Compilererror: "{0}" at row {1}'.format(self.msg, self.loc.row)
+        else:
+            return 'Compilererror: "{0}"'.format(self.msg)
 
 def printError(source, e):
      def printLine(row, txt):