Last instruction executed before an error

Hi I would like to understand if there is a way to intercept the last instruction executed before an error occurs (obviously by executing the code from the xojo ide, therefore in debug mode).

I saw that it is possible to add the line number to the code, I would like to understand if (perhaps with introspection), when an error “intercepted” by a catch occurs, it was possible to trace the function, subroutine, webpage, webcontrol and number of the line of code executed before the error was triggered.

thank you all

On the Project menu, select “Break on exceptions” and then run your code. Xojo will stop at the line that caused the error, even if you have any form of error handler in place.

2 Likes

The exception that you catch contains this information (though not the line number). Catch the exception with a variable to access it.

try
  // my code

catch ex as TypeOfException
  // The ex.Stack property is an array that is what you're looking for

end try
1 Like

plus
https://documentation.xojo.com/api/language/pragma_directives.html
#Pragma BreakOnExceptions False
#Pragma BreakOnExceptions Default

1 Like