-
-
Notifications
You must be signed in to change notification settings - Fork 11
Description
Background
Currently, the parsing, synthesis, and simulation functions in mqt-syrec emit errors to stderr rather than throwing exceptions. However, third-party code (ANTLR runtime, mqt-core) may throw exceptions that are not currently handled.
Related PR
This issue was created as a follow-up to PR #486, where stderr redirection was added to capture synthesis errors in the Python editor.
Discussion: #486 (comment)
Proposed Solutions
There are two potential approaches to handle exceptions from third-party code:
-
Python Editor Approach: Add try-catch blocks in the Python editor (
python/mqt/syrec/syrec_editor.py) to wrap calls tocost_aware_synthesis,line_aware_synthesis, and other mqt-syrec functions. -
Pybind11 Bindings Approach: Add try-catch blocks in the pybind11 bindings (
bindings/bindings.cpp) for the C++ functions to catch exceptions from third-party code and convert them to appropriate Python exceptions or error messages.
Current Status
- mqt-syrec C++ code does not currently use try-catch blocks
- The Python editor captures stderr output for error reporting
- Exceptions from third-party code may propagate uncaught to the user
Next Steps
Evaluate both approaches and implement exception handling that:
- Catches exceptions from third-party dependencies
- Provides meaningful error messages to users
- Maintains consistency with the current stderr-based error reporting pattern
- Considers whether C++ try-catch blocks should be added to mqt-syrec itself
Requested by: @TooMuchDakka