Browse Source

VisitError now allows explicit access to previous exception (Issue #314)

tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.6.6
Erez Shinan 6 years ago
parent
commit
6a6dd97c52
2 changed files with 7 additions and 2 deletions
  1. +6
    -1
      lark/exceptions.py
  2. +1
    -1
      lark/visitors.py

+ 6
- 1
lark/exceptions.py View File

@@ -87,5 +87,10 @@ class UnexpectedToken(ParseError, UnexpectedInput):
super(UnexpectedToken, self).__init__(message)

class VisitError(Exception):
pass
def __init__(self, tree, orig_exc):
self.tree = tree
self.orig_exc = orig_exc

message = 'Error trying to process rule "%s":\n\n%s' % (tree.data, orig_exc)
super(VisitError, self).__init__(message)
###}

+ 1
- 1
lark/visitors.py View File

@@ -43,7 +43,7 @@ class Transformer:
except GrammarError:
raise
except Exception as e:
raise VisitError('Error trying to process rule "%s":\n\n%s' % (tree.data, e))
raise VisitError(tree, e)

def _transform_children(self, children):
for c in children:


Loading…
Cancel
Save