urho icon indicating copy to clipboard operation
urho copied to clipboard

UnhandledException handler never called

Open deakjahn opened this issue 6 years ago • 6 comments

Exceptions occurring in deeper Urho layers always seem to bring down the whole app. I do subscribe to UnhandledException:

static MyModel() {
  UnhandledException += (s, e) => {
    Logger.Log.Error(e.Exception.Message);
    e.Handled = true;
  };
}

The exception can come from actual usage or can be triggered manually for testing by a throw new ApplicationException() either from Start() or OnUpdate() routines. The handler doesn't get called, the platform app exception handling is notified instead.

I have both

model = await Surface.Show<MyModel>(options);

and

await modelNode.RunActionsAsync();

inside their own try-catch for added safety.

Update: I checked it on Android, too. The situation is the same.

deakjahn avatar Nov 29 '18 13:11 deakjahn

If those deep bits are hit from your update(), then a try/catch in update() seems to fix them for me?

hwd71 avatar Nov 29 '18 13:11 hwd71

For testing, I just put a throw new ApplicationException() into my Start(). But on an actual machine with an older video card I can get regular DirectX sampler errors that Urho has nothing to do with, still, I'd be happy to catch them and inform the user rather than blowing up.

The unhandled handler gets called all right, I can log whatever error it signals, just that it goes on and crashes anyway.

deakjahn avatar Nov 29 '18 13:11 deakjahn

I'd expect that to be try/catch'd as well.. and probably also any input events, e.g. touch, mouse. Same with droid, winforms, etc.

Ah, I see - I don't get that; my update() continue OK. I guess if your Start() fails then that's more serious. Generally I get nice warnings in the Log for missing resources etc. Haven't used it with DirectX.

hwd71 avatar Nov 29 '18 13:11 hwd71

I would, too. :-)

deakjahn avatar Nov 29 '18 13:11 deakjahn

If you compile for UWP, you do use DirectX. But that's just an illustration of where my actual exceptions can come from.

deakjahn avatar Nov 29 '18 13:11 deakjahn

I don't get most of the urho exceptions in the managed code handlers but do get them in the Application handler. In Main(), I set:

Application.UnhandledException += Application_UnhandledException;

And this catches nearly everything the managed catches don't. Some errors do seem to slip through especially when memory gets corrupted

utekai avatar Feb 02 '19 21:02 utekai