Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Conversation

@cgranade
Copy link
Contributor

@cgranade cgranade commented Mar 4, 2020

This PR uses the OnException event introduced by microsoft/qsharp-runtime#157 to format exception stack traces as an HTML details element, making it easier to hide extraneous information while still allowing interested users to drill down through stack traces.

Collapsed:
image

Expanded:
image

When stack traces contain more useful information (e.g.: source locations for library functions and operations), that information is formatted as a hyperlink using @vadym-kl's logic for finding best source locations added in microsoft/qsharp-runtime#79.

This PR is marked as draft in lieu of API docs (#98) and feedback on the UI design, as well as the completion of microsoft/qsharp-runtime#157.

anpaz
anpaz previously approved these changes Mar 10, 2020
Copy link
Member

@anpaz anpaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The magic for the other simulators (%toffoli, %estimate) should get the same treatment.
How does it look when this is triggered on Python?

@cgranade
Copy link
Contributor Author

@anpaz-msft: Thanks for the feedback! I've confirmed that the Python output is unaffected, since the changes here set up result encoders for both text/plain and text/html (see screenshot below). I've also added the same logic to %toffoli and %estimate. Once I've finished API docs, I'll mark this as being ready. Thanks!

image

@cgranade cgranade marked this pull request as ready for review March 12, 2020 18:56
@cgranade cgranade requested a review from anpaz March 17, 2020 01:25
Copy link
Member

@vxfield vxfield left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been following this for two week and the code is good.
Suggested (future) improvements:

  1. Create a IResultEncoder and use some reflection for registering/invoking the encoders.
  2. Create a generic encoder XsltResultEncoder<> : IResultEncoder, use a Xslt to transform the object to HTML or Text. The advantage for that is less code to maintain and make it more declarative using the templates.
    I did some tests and it's also working fine.

@cgranade cgranade merged commit d12c9be into master Mar 19, 2020
@cgranade
Copy link
Contributor Author

Thanks for the review, @vxfield, and for the suggestions for future improvements! I think that could work great for improving how result encoders work going forward.

@cgranade cgranade deleted the cgranade/on-exception branch March 19, 2020 23:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants