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

Enabling simulators OnFail event when exception is thrown #59

Merged
merged 5 commits into from Oct 7, 2019

Conversation

@vadym-kl
Copy link
Member

vadym-kl commented Sep 26, 2019

This implements #58.

@vadym-kl vadym-kl requested review from thomashaener and anpaz-msft Sep 26, 2019
Copy link

thomashaener left a comment

Looks good!

src/Simulation/Simulators.Tests/CoreTests.cs Outdated Show resolved Hide resolved
@@ -21,6 +21,7 @@ public abstract class SimulatorBase : AbstractFactory<AbstractCallable>, IOperat
{
public event Action<ICallable, IApplyData> OnOperationStart = null;
public event Action<ICallable, IApplyData> OnOperationEnd = null;
public event Action<System.Runtime.ExceptionServices.ExceptionDispatchInfo> OnFail = null;

This comment has been minimized.

Copy link
@anpaz-msft

anpaz-msft Sep 27, 2019

Contributor

I hate to ask, but what is the ExceptionDispatchInfo, and do we really need to provide it?

This comment has been minimized.

Copy link
@vadym-kl

vadym-kl Sep 27, 2019

Author Member

ExceptionDispatchInfo contains exception itself and relevant debugging information from the moment exception was thrown. So if you say wanted to say access the call-stack of the exception at the moment when it was thrown, you could do it. Original exceptions is available through ExceptionDispatchInfo.SourceException property.

From the docs:

The ExceptionDispatchInfo object stores the stack trace information and Watson information that the exception contains at the point where it is captured. The exception can be thrown at another time and possibly on another thread by calling the ExceptionDispatchInfo.Throw method. The exception is thrown as if it had flowed from the point where it was captured to the point where the Throw method is called.

I thought it might be nice sometimes to know about the call-stack at the moment when exception was thrown.
But I am fine with just passing an exception itself.

This comment has been minimized.

Copy link
@vadym-kl

vadym-kl Sep 27, 2019

Author Member

If you think that ExceptionDispatchInfo is an overkill, I could change the argument back to just Exception.

vadym-kl and others added 3 commits Sep 27, 2019
Co-Authored-By: Andres Paz <anpaz@microsoft.com>
Co-Authored-By: Andres Paz <anpaz@microsoft.com>
…ions
@vadym-kl vadym-kl merged commit 20c693a into master Oct 7, 2019
2 checks passed
2 checks passed
license/cla All CLA requirements met.
Details
microsoft.qsharp-runtime #0.9.1910.706 succeeded
Details
@anpaz-msft anpaz-msft deleted the vadym-kl/58-notify-simulators-about-exceptions branch Oct 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.