Finding an unhandled exception

What does you code do if you have an exception inside App.UnhandledException itself?

Other ideas:

  • possibly you are having a Cocoa exception which can cause a method to silently exit - run your app with Console.log open and your appā€™s name in the search box.
  • Or, you could try making sure your app quits on exceptions: See Crash an application on NSException - #2 by Scott_Cadillac (Though, I think this already happens on High Sierra?)
  • add this line as the very first line of app.UnhandledException:
    system.debugLog "unhandled exception!!!"
    (just to prove to yourself this handler is or is not firing)
1 Like

Could it be that in the App.UnhandledException you have a NilObjectException causing it to be skipped or hard crashing?

So maybe you could put this above in the App.UnhandledException:

Var exception_type As String = Introspection.GetType(err).Fullname
system.log system.loglevelcritical, "!<>! " + CurrentMethodName + ", " + exception_type  + ", " + err.message

Then run it with Console.App open and filter on ā€œ!<>!ā€

My guess is that it is occurring in a control, and potentially from a declare or plugin, maybe even on a different thread, so for some reason itā€™s skipping the built-in Exception handling code from Xojo.

@Beatrix_Willius
I donā€™t see anything above soā€¦ are you returning True or False from the UnhandledException method? Iā€™m asking because if returning False (or nothing) trying to show a window will outright fail because the app will be allowed to crash.

Thatā€™s a really good question. I donā€™t think I ever had the UnhandledException fire. At all. I tried with a method where I commented out the exception handler

dim f as FolderItem
f.Delete

'exception exc
'theException = new ErrorException(exc, currentMethodName)

But even there I get the normal exception behaviour.

Anyways. I wrangled with the SVN. Whatever I merged from before the NOE with the current version all is now good.

So sadā€¦ Now weā€™ll never know what went wrong :wink:

1 Like

Just Murphy paying a brief visit.

2 Likes

Murphy always returnsā€¦ best to say hi and have a long discussion with him whenever you can.

3 Likes