try catch - exception not triggered

1 try
2 jdate = jrecord.Child(“releasegroups”).Child(0).Child(“releases”).Child(0).Child(“date”)
3 catch err as KeyNotFoundException
4 jdate = jrecord.Child(“releasegroups”).Child(0).Child(“releases”).Child(1).Child(“date”)
5 end try

On Mac, when I run the app, the prog stops on line 2 -> tooltip KeyNotFoundException on the red bug picto
BUT the exception is not triggered i.e. line 4 is note executed !

Please help.

Are you sure that line 4 is not executed?
Have you tried a step in the debugger?

Are you sure that line 4 doesn’t fire another KeyNotFoundException and so you saw the global KeyNotFoundException alert message?

Just tried this:
dim jrecord as new jsonitem //empty so I’m sure it will trigger the KeyNotFoundException
dim jdata as jsonitem
jdate = jrecord.Child(“releasegroups”).Child(0).Child(“releases”).Child(0).Child(“date”)
catch err as KeyNotFoundException
//jdate = jrecord.Child(“releasegroups”).Child(0).Child(“releases”).Child(1).Child(“date”)
end try

The step debug works as expected and noglobal KeyNotFoundException alert message is fired.

Are you running in the debugger ?
Do you have “break on exceptions” in the Program menu enabled ?
If so then the exception IS being raised & the debugger is showing you that - by breaking into the debugger
Stepping will show you whether your code handles the exception or not
If you turn that setting OFF then exceptions will not break into the debugger but WILL probably cause your debug app to raise an exception & cease working

I’ve set option “break on exception” to off and now the exception is catched
Thanks Norman!

Its always been caught as long as your code was catching things correctly.
The “break on exceptions” just did a break when the exception was raised - you could still hit RESUME at that point or step to watch your code catch the exception.

I pretty much leave that setting on all the time as it can help me find exceptions that I am NOT expecting