From a0a0d153958b6623cf9b016b80b84c2fd18f961d Mon Sep 17 00:00:00 2001 From: Florian Deconinck Date: Tue, 10 Sep 2024 11:17:38 -0400 Subject: [PATCH] [Minor] Print out exception on parsing fail early (#1651) 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 --- dace/frontend/python/newast.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dace/frontend/python/newast.py b/dace/frontend/python/newast.py index 46db3a3a5d..1b11fb00c6 100644 --- a/dace/frontend/python/newast.py +++ b/dace/frontend/python/newast.py @@ -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):