You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While using OnException to catch exceptions. I sort of want to be able to inform the user of things going wrong with a dialog.
How ever, if the exception that gets thrown belongs to a sub in the call stack, the OnException will get triggered all the way to its origin place.
Is there any proper way to keep track if this is the first triggered 'OnException' in the call stack chain?
As in my case, there only needs to be one dialog triggered by this, and not lets say five, reporting on the same issue, just on different levels of the call stack.
public override void OnException(MethodExecutionArgs args)
{
//Some kind of if-statement
//Show exception in dialog window.
}
The text was updated successfully, but these errors were encountered:
I don't understand how there can be multiple exceptions in one user action. Do you mean when using concurrent/parallel method calls?
All in all I would prefer using the unhandled exception handler of your UI/message pump framework to intercept exceptions as last resort and then show the corresponding dialog.
For WPF check this out: WPF unhandled exception handler
If you really want to track the call stack chain longer than the lifetime of the aspect then you have to use a static variable or enforce a policy that the instance of the current method call have an interface which provides a property to store this information.
The stack trace can be retrieved via reflection and stack trace
But this solution would be a big code smell for me :D
While using
OnException
to catch exceptions. I sort of want to be able to inform the user of things going wrong with a dialog.How ever, if the exception that gets thrown belongs to a sub in the call stack, the
OnException
will get triggered all the way to its origin place.Is there any proper way to keep track if this is the first triggered 'OnException' in the call stack chain?
As in my case, there only needs to be one dialog triggered by this, and not lets say five, reporting on the same issue, just on different levels of the call stack.
public override void OnException(MethodExecutionArgs args)
{
//Some kind of if-statement
//Show exception in dialog window.
}
The text was updated successfully, but these errors were encountered: