Skip to content

Commit

Permalink
[Minor] Print out exception on parsing fail early (#1651)
Browse files Browse the repository at this point in the history
Minor QOL feature: print the exception early when failing parsing. When
debugging code base that are 8 or 9 level of class/functions deep, it
helps with obvious errors.

---------

Co-authored-by: Florian Deconinck <[email protected]>
  • Loading branch information
FlorianDeconinck and Florian Deconinck authored Sep 10, 2024
1 parent 16e09b1 commit a0a0d15
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dace/frontend/python/newast.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,10 @@ def repl_callback(repldict):
ProgramVisitor.increment_progress()
except SkipCall:
raise
except Exception:
except Exception as e:
# Print the offending line causing the exception
li = visitor.current_lineinfo
print(f'Exception raised while parsing DaCe program:\n in File "{li.filename}", line {li.start_line}')
print(f'Exception {e} raised while parsing DaCe program:\n in File "{li.filename}", line {li.start_line}')
lines = preprocessed_ast.src.split('\n')
lineid = li.start_line - preprocessed_ast.src_line - 1
if lineid >= 0 and lineid < len(lines):
Expand Down

0 comments on commit a0a0d15

Please sign in to comment.