urho
urho copied to clipboard
UnhandledException handler never called
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.
If those deep bits are hit from your update(), then a try/catch in update() seems to fix them for me?
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.
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.
I would, too. :-)
If you compile for UWP, you do use DirectX. But that's just an illustration of where my actual exceptions can come from.
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