Commit 637bee47 authored by Tom Niget's avatar Tom Niget

Handle invalid nodes in exception display

parent b1f44165
import ast
from dataclasses import dataclass
from transpiler.utils import UnsupportedNodeError from transpiler.utils import UnsupportedNodeError
...@@ -10,12 +14,20 @@ class NodeVisitorSeq: ...@@ -10,12 +14,20 @@ class NodeVisitorSeq:
else: else:
for parent in node.__class__.__mro__: for parent in node.__class__.__mro__:
if visitor := getattr(self, 'visit_' + parent.__name__, None): if visitor := getattr(self, 'visit_' + parent.__name__, None):
return visitor(node) try:
return visitor(node)
except Exception as e:
raise
#raise IncompatibleTypesError(f"{e} in `{ast.unparse(node)}`")
else: else:
self.missing_impl(node) self.missing_impl(node)
def missing_impl(self, node): def missing_impl(self, node):
raise UnsupportedNodeError(node) try:
raise UnsupportedNodeError(str(node))
except Exception as e:
raise NotImplementedError(type(node))
@dataclass @dataclass
class PlainBlock(ast.stmt): class PlainBlock(ast.stmt):
body: list[ast.stmt] body: list[ast.stmt]
\ No newline at end of file
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