Commit 61ea6032 authored by 's avatar

Change exceptions to store lineno and offset info in separate attributes,

for consistency with nsgmllib and expat.
parent a476259a
...@@ -111,16 +111,18 @@ KNOWN_TAL_ATTRIBUTES = [ ...@@ -111,16 +111,18 @@ KNOWN_TAL_ATTRIBUTES = [
] ]
class TALError(Exception): class TALError(Exception):
def __init__(self, msg, position=None): def __init__(self, msg, position=(None, None)):
assert msg != ""
self.msg = msg self.msg = msg
self.position = position # (line, offset) pair self.lineno = position[0]
self.offset = position[1]
def __str__(self): def __str__(self):
if self.position: result = self.msg
result = "%s, at line %d, column %d" % ( if self.lineno is not None:
self.msg, self.position[0], self.position[1]+1) result = result + ", at line %d" % self.lineno
else: if self.offset is not None:
result = self.msg result = result + ", column %d" % (self.offset + 1)
return result return result
class METALError(TALError): class METALError(TALError):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment