1.1 --- a/simplified.py Mon Oct 16 00:36:34 2006 +0200
1.2 +++ b/simplified.py Mon Oct 16 00:39:44 2006 +0200
1.3 @@ -24,6 +24,35 @@
1.4 from compiler.visitor import ASTVisitor
1.5 import sys
1.6
1.7 +# Exceptions.
1.8 +
1.9 +class SimplifiedError(Exception):
1.10 +
1.11 + "An error in the annotation process."
1.12 +
1.13 + def __init__(self, exc, node, *args):
1.14 +
1.15 + """
1.16 + Initialise the error with an existing exception 'exc', the 'node' at
1.17 + which this error occurs, along with additional optional arguments.
1.18 + """
1.19 +
1.20 + Exception.__init__(self, *args)
1.21 + self.nodes = [node]
1.22 + self.exc = exc
1.23 +
1.24 + def add(self, node):
1.25 +
1.26 + "Add the given 'node' to the path of nodes leading from the exception."
1.27 +
1.28 + self.nodes.append(node)
1.29 +
1.30 + def __str__(self):
1.31 +
1.32 + "Return a string showing the principal exception details."
1.33 +
1.34 + return "%s, %s" % (self.exc, self.nodes)
1.35 +
1.36 # Unique name registration.
1.37
1.38 class Naming: