Out of bounds error in script causes out of bounds error in app?

Trying to get a handle on using Xojoscript.

I’m using Xojoscript objects in the app I’m working on, and just throwing some bad script code
at it, while trying to present the user with nice error messages.

I just tested how an out of bounds error would handle in a script.

So basically I just dim a fixed array in a script and use a for loop to step it out of bounds triggering an error.

This caused an outofbounds exception on “xojoscript.run” and dropped me into the debugger.

Shouldn’t that just have generated a runtime error in the script that I could handle in the RuntimeError event?

No, but it should call the XojoScript.RuntimeError event handler. Create a XojoScript subclass to get easier access to it.

Oh sorry forgot to mention I already did that.

I created my own class subclassed from XojoScript and I have the error handler events setup for that class which is where I grab the error and line number and present it to the user.

I did stick some code in the RuntimeError event handler, but it still drops me into the debugger on objXojoScript.run because of the out of bounds error in the script, and never calls RuntimeError.

I have CompilerError and CompilerWarning set up and provoked them via a script to trigger and they both get fired so not sure why RuntimeError doesn’t get called.

Nevermind, total PEBKAC moment lmao

Had “break on exceptions” on, that’s why I couldn’t understand why I got dropped into the debugger.

Must have hit “break on exceptions” by accident since I use clear breakpoints a lot and that menu is right next to it.

Kenneth, I did exactly what you descibe but the XojoScript.RuntimeError event handler is not called in Xojo 2015.r2.2. The application just crashes after reporting the expected error in a message box. Is it working for you?

Works fine here. If I try to access an element of an array that does not exist, RunTimeError fires just fine.

Could the error be in the Print event ? That would explain the outOfBound at the app level.