Skip to content

Add exception handling for parsing, synthesis, and simulation functions #488

@coderabbitai

Description

@coderabbitai

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:

  1. Python Editor Approach: Add try-catch blocks in the Python editor (python/mqt/syrec/syrec_editor.py) to wrap calls to cost_aware_synthesis, line_aware_synthesis, and other mqt-syrec functions.

  2. 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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions