UnhandledException basics

I want to learn how to use this to debug an app. I’ve turned on Include Function Names in the Shared Build Settings. Would I be correct to assume that this will then pass up the function names to the app level. I’ve added the UnhandledException event to the App but I’m not sure how to collect the error and log it? What I’ve got is:

Exception err as RuntimeException Dim vErrNumber, vErrMsg as String vErrNumber = Str(err.ErrorNumber) vErrMsg = err.message
Then I log it into a database table. Though this compiles without an error I’m not sure I got this right. Thanks.

The function names are included in RuntimeException.Stack as a string array. The function at index 0 is the most recent function called before the exception was Raised, 1 is the next most recent, etc.

For example, here’s an unhandled exception that was raised in Window1.Pushbutton1.Action

Window1.Window1.PushButton1_Action%%o<Window1.Window1>o<PushButton> Delegate.IM_Invoke%%o<PushButton> AddHandler.Stub.15%% Delegate.Invoke%% Application._CallFunctionWithExceptionHandling%%o<Application>p REALbasic._RuntimeRun _Main % main

Thanks. I’m not sure where and how this data gets saved? All the errors that I’m trapping now are getting written to a table in a database. So I understand what the data is but how do I get at it after the app crashes?

It doesn’t get saved anywhere. You have to save it in UnhandledException. Or email it to yourself. Or…

OK, that’s my question then. How do you do any of that? Can I capture it as I’ve described in the top post?

It would something like this:

Exception err as RuntimeException
  Dim vErrNumber, vErrMsg, vErrStack() as String
  vErrNumber = Str(err.ErrorNumber)
  vErrMsg = err.message
  vErrStack = err.Stack

Excellent, thank you. Thankfully this has only happened a couple of times in the first month. That’s what makes it hard to debug.