-
-
Notifications
You must be signed in to change notification settings - Fork 32
🎨 Stremline error handling #834
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -76,7 +76,7 @@ def generate_header( | |
| "The Python package `mqt.bench` is not installed in the current " | ||
| "environment. Install it with\n\n" | ||
| " pip install mqt.bench\n\n" | ||
| f"and try again. (Original error: {exc})" | ||
| "and try again." | ||
| ) | ||
| raise MQTBenchExporterError(msg) from exc | ||
|
|
||
|
|
@@ -155,7 +155,7 @@ def write_circuit( | |
| destination.write(header) | ||
| (dump2 if fmt is OutputFormat.QASM2 else dump3)(qc, destination) | ||
| except Exception as exc: # pragma: no cover - unforeseen I/O | ||
| msg = f"Failed to write QASM stream. (Original error: {exc})" | ||
| msg = "Failed to write QASM stream." | ||
| raise MQTBenchExporterError(msg) from exc | ||
| return | ||
|
|
||
|
|
@@ -166,7 +166,7 @@ def write_circuit( | |
| try: | ||
| dump_qpy(_attach_metadata(qc, header), destination) | ||
| except Exception as exc: | ||
| msg = f"Failed to write QPY stream. (Original error: {exc})" | ||
| msg = "Failed to write QPY stream." | ||
| raise MQTBenchExporterError(msg) from exc | ||
| return | ||
|
|
||
|
|
@@ -179,15 +179,15 @@ def write_circuit( | |
| f.write(header) | ||
| (dump2 if fmt is OutputFormat.QASM2 else dump3)(qc, f) | ||
| except Exception as exc: | ||
| msg = f"Failed to write {fmt.value.upper()} file to {destination}. (Original error: {exc})" | ||
| msg = f"Failed to write {fmt.value.upper()} file to {destination}." | ||
| raise MQTBenchExporterError(msg) from exc | ||
|
Comment on lines
181
to
183
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removing
assert "disk full" in msg.lower() # msg = str(exc.value)
The same applies to lines 158, 169, and 190 (stream and QPY paths), though those are not exercised by this particular test case. Either update the test to drop the 🛠️ Option A — Update the test (aligned with PR intent) msg = str(exc.value)
assert "failed to write qasm2 file" in msg.lower()
-assert "disk full" in msg.lower()🛠️ Option B — Re-embed the exception in the message- msg = f"Failed to write {fmt.value.upper()} file to {destination}."
+ msg = f"Failed to write {fmt.value.upper()} file to {destination}: {exc}."🤖 Prompt for AI Agents |
||
|
|
||
| elif fmt is OutputFormat.QPY: | ||
| try: | ||
| with destination.open("wb") as f: | ||
| dump_qpy(_attach_metadata(qc, header), f) | ||
| except Exception as exc: | ||
| msg = f"Failed to write QPY file to {destination}. (Original error: {exc})" | ||
| msg = f"Failed to write QPY file to {destination}." | ||
| raise MQTBenchExporterError(msg) from exc | ||
|
|
||
| else: | ||
|
|
@@ -220,7 +220,8 @@ def save_circuit( | |
| try: | ||
| write_circuit(qc, path, level, output_format, target) | ||
| except MQTBenchExporterError as e: | ||
| print(e) | ||
| cause = f": {e.__cause__}" if e.__cause__ else "" | ||
| print(f"{e}{cause}") | ||
| return False | ||
|
|
||
| return True | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.