These are chat archives for exceptionless/Discuss

15th
Oct 2015
Magnus Lindhe
@mgnslndh
Oct 15 2015 08:47
How about adding an event to ExceptionlessClient that will fire when any unhandled exception is caught by any of its event handlers (UnobservedTask, AppDomain, Dispatcher, Application). Before the exception is submitted as an error event. I could then have a chance to log it locally. Or perhaps there already is some functionality like this?
Magnus Lindhe
@mgnslndh
Oct 15 2015 09:08
Actually I think that event should fire for errors before/after the crash dialog.
If I listen to the event that fires after the crash dialog I can log and perhaps decide to terminate the application.
Blake Niemyjski
@niemyjski
Oct 15 2015 10:58
@mgnslndh We have a submiting event that fires before the error is queued for submission. It also has a flag that you can check to see if it’s Unhandled and you can also cancel it so it’s not submitted
Magnus Lindhe
@mgnslndh
Oct 15 2015 11:21
But the event is never fired if the user press "Cancel" on the dialog.
Blake Niemyjski
@niemyjski
Oct 15 2015 11:22
Could because they cancled it before submitting was called.
let me look
Magnus Lindhe
@mgnslndh
Oct 15 2015 11:23
The flow I am looking for is to do some cleaning and then shutdown the application when I have an unhandled exception. I could subscribe to all the necessary events and do it that way but I thought it would be nice if Exceptionless could provide a single event when it knows there is an unhandled exception that has been submitted or not (cancel on dialog).
The dialog ask if the user wants to submit a crash report or not. Either way I want to shutdown the application. Since I am using Exceptionless it would be nice to hook into its flow instead of hooking up several other event handlers that must run after Exceptionless. I mean it can be done without Exceptionless but it would be easier to have a little less plumbing to think about.
Blake Niemyjski
@niemyjski
Oct 15 2015 11:26
The reason you are seeing that behavior is because they are wiring up to OnSubmitting before you
so if you wired up to that event handler first (before you call Startup) it would be hit
We really only have that one event handler that gets called
and if you wire up to it first you will be good to go
Are you going to sbumit the errors before shutting down or just call shut down?
submission should happen when you call exit
Can you try this and let me know
Magnus Lindhe
@mgnslndh
Oct 15 2015 11:29
I want the user to choose by showing the dialog. After the dialog I would like to shutdown. I would also like to have access to the Exception object that caused the crash.
Ok. Submission always occur on exit? I use Environment.FailFast() but I guess that could be a problem then.
Blake Niemyjski
@niemyjski
Oct 15 2015 11:31
I’d recommend testing it but yes it should
We never tested fail fast with submission
You have access to all of that in the OnSubmission handler
we might need to abstract the showing of the dialog because you want to handle that yourself and exit.
Magnus Lindhe
@mgnslndh
Oct 15 2015 11:33
But I still dont see how I could shutdown after the dialog has been shown if the error is not submitted.
Blake Niemyjski
@niemyjski
Oct 15 2015 11:33
If you look at that ExceptionlessClient, the wpf extensions you can see the flow of what happens
currently, you’d have to show the dialog yourself
You’d have to register a handler on OnSubmitting (and show the dialog) and then to pass false to the Register(false) method which will prevent the wpf client from showing that dialog
that would give you complete control over this.
Magnus Lindhe
@mgnslndh
Oct 15 2015 11:35
Yes. I'll have a look at it and maybe do a pull request. Would you consider a new event if I show a solution for it or would you rather prefer I solve it some other way?
Blake Niemyjski
@niemyjski
Oct 15 2015 11:35
If we abstracted the showing of the dialog behavior, it would make this a bit easier
I beleive there is a recently opened github issue round this
I think it would be better to use the existing event, and be better to abstract the showing of the dialog in a generic way
Magnus Lindhe
@mgnslndh
Oct 15 2015 11:36
Ah, so if I hook up my own handler and show the dialog and deal with the dialog result I can then shutdown for both "Submit" and "Cancel".
Blake Niemyjski
@niemyjski
Oct 15 2015 11:36
yes :)
Magnus Lindhe
@mgnslndh
Oct 15 2015 11:37
Ok, just a quick question then. Is it possible to get hold of the original Exception object somehow?
Blake Niemyjski
@niemyjski
Oct 15 2015 11:37
it should be straight foward just make sure you pass Register(false) so we don’t show that dialog.. and then you’d have to show it..
yes
Magnus Lindhe
@mgnslndh
Oct 15 2015 11:38
GetError() returns a model of the error and I have not found a property or method for accessing the original Exception.
Blake Niemyjski
@niemyjski
Oct 15 2015 11:38
    private static void OnSubmittingEvent(object sender, EventSubmittingEventArgs e) {
        //error.ExceptionlessClientInfo.Platform = ".NET WPF";
        if (!e.IsUnhandledError)
            return;

        var exception = e.PluginContextData.GetException();

        if (Application.Current != null && !Application.Current.Dispatcher.CheckAccess())
            e.Cancel = !(bool)Application.Current.Dispatcher.Invoke(new Func<EventSubmittingEventArgs, bool>(ShowDialog), DispatcherPriority.Send, e);
        else
            e.Cancel = !ShowDialog(e);
    }
You’d have to get it from the plugin context which if you inspect it contains everything that the plugins have access to (same contexT)
Magnus Lindhe
@mgnslndh
Oct 15 2015 11:39
Ah, the context. Great! Now, I can solve both my issues.
Blake Niemyjski
@niemyjski
Oct 15 2015 11:39
we have some helper methods on it too
Magnus Lindhe
@mgnslndh
Oct 15 2015 11:40
Thanks a bunch! :)
Blake Niemyjski
@niemyjski
Oct 15 2015 11:40
no problem. If you have any questions or think something could be easier let us knwo
I think we could make the showing of the dialog easier by abstracting it/injecting it into the di system