Is there a list of error codes for things like NilObjectExceptions

Is there a list in Xojo of various errors (their numbers) that can be caught and acted upon?

I found a list for database errors, but am wondering if there are others.

Regards

There’s a list of the RuntimeExceptions, but not very much in the way of “this function can raise this type of exception.”

RuntimeException — Xojo documentation

1 Like

There should be!

2 Likes

i guess it does not exists because errors comes from different sources, third party librarys, different os versions. basically each of them should have a error list documentation.

at least here is a list of different kinds.
https://documentation.xojo.com/api/exceptions/runtimeexception.html

Catch e As XMLException
  MessageBox("Error " + e.ErrorNumber.ToString + " " + e.Message)

Xojo typically provides error lists specific to databases; other lists vary per functionality used.

I have a question about bugs, I’m taking advantage of this thread because I didn’t want to create one for this.
When we have a bug in Debug mode, Xojo stops where the bug is. Is it a way to Xojo indicate the Method’s name, of the event’s name in a built app?
Except reviewing all my source project to add in each Method and event:

Exception TypErr
MessageBox "MyMethodName: " + TypErr.Message + " n° "  str(TypErr.ErrorNumber)

You can use CurrentMethodName to receive a string indicating which method you’re currently in.

1 Like

There is the CurrentMethodName constant…

1 Like

Ok, thank you, but I have still to add

Exception TypErr
MessageBox CurrentMethodName + TypErr.Message + " n° "  str(TypErr.ErrorNumber)

in each Method and event of all my source project.
I was hoping a checkbox “Display MethodName when crash” in the IDE exists.

I checked long time ago “Include Function Names” but it seems to be something else.

Assuming you are referring to an ancaught exception, just dump the stack in your app’s UnhandlesException handler.

Getting the current method name from the stack isn’t quite so simple, but if you want direction when an exception occurs and you’re not sure where it happened, Tim’s right. Dump the stack for inspection.

This will give you the lines of the stack in a single string that you can send off using an error reporter or log to a file easily:

var stack as string = String.FromArray( TypErr.Stack, EndOfLine )

Then also @Beatrix_Willius provided us with a nice “stack cleaner” method to remove unwanted stuff from the stack dump.

When user send me an email to report a crash, they join a screencapture where I can ser the MessageBox “An Nil exception occur and was not handled etc.”. If it could display the MethodName it would help me.

Note: I shut down my Mac and I can’t make an screencapture of the MessageBox. Time to eat and watch a movies in France :slight_smile: .

It is a little bit work, but I would suggest to switch to Jeremie_L’s Sentry Client to get errorreports without any user interaction necessary.

Sentry has a free plan, can host your data in Europe (if desired) and the client is working silently in the background - you no longer depend on users error descriptions and if they like to send you a report or not.

Just so you’re aware, sentry is blocked by default with privacy protection systems like Pi-hole. You may wish to use your own service / website instead.

Good to know @Tim_Parnell

Along these lines and if folks don’t want to try and reinvent the wheel, I’ve been very happy with @Christian_Schmitz’s Bug Reporter Kit. It’s pure Xojo code, so it also makes for a great starting point to build and tweak to your own liking. Note that it does require use of some of the MBS plugins.

At one time the kit was a standalone product but starting with version 1.6 released in August of 2023, it’s now included for free within the MBS Xojo Complete Plugin Set.

Also not to turn this into a vendor peddling per se, but I’ve paired it up with DoneDone for a support mailbox and bug tracker.

Thank you, but I don’t think I will use that. I’m not good enough to manage those bugs reports. I just wanted to see in which Method the crash occurred.
On the Xojo documentation I can read:

  • Include Function Names: When ON, the actual names of your function calls are embedded in the built app. This is useful for debugging purposes and for getting stack traces.

But where does this appear? In the System crashlog? If yes, it doesn’t help me as I don’t know read a crash log. But if the crashlog can get the Method name, it could bepossible to showh it in the MessageBox displayed before the application quits, no?

It appears in the stack traceback, at least. That’s why I leave that setting turned ON. But at crash time (such as unhandled exception), it’s your job to access the stck traceback and print it, save to a log file …