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.