Skip to content
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

%%qsharp cell failures should mark the cell as failed #1071

Merged
merged 2 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions pip/qsharp/_ipython.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def callback(output):
return get_interpreter().interpret(cell, callback)
except QSharpError as e:
display(Pretty(str(e)))
raise QSharpCellError()


def enable_classic_notebook_codemirror_mode():
Expand All @@ -44,3 +45,16 @@ def __repr__(self):

# This will run the JavaScript in the context of the frontend.
display(JavaScriptWithPlainTextFallback(js_to_inject))


class QSharpCellError(BaseException):
"""
Error raised when a %%qsharp cell fails.
"""

def _render_traceback_(self):
# We want to specifically override the traceback so that
# this error is not shown in the notebook cell output. We will
# always dump the Q# error directly from the interpreter,
# so the Python error information is unnecessary and distracting.
return [" "]
Loading
Loading