I’m trying to get the application.setErrorCapture(true) function to work. I’d like to trap for errors extensively so that clients won’t see JS/Servoy’s error message and will instead see mine as is done in FM. But when I use the following script, I still see the Servoy error message and it seems the method just stops after line 2 and never goes on to set the errorfield.
1 application.setErrorCapture(true);
2 go = go;
3 errorfield = application.getLastErrorCode();
4 plugins.dialogs.showInfoDialog( ‘Error’, 'The last error code was: ’ +
errorfield, ‘OK’);
I’ve looked in both the adv. prog guide and the Dev manual and both provide the syntax for these functions but don’t seem to describe how to use them in practice or what they do. Is there somewhere else I should look?
I’m sorry, can you be more clear? As I said, I need users not to see the standard JS/Servoy error message and I need the script not to just stop running - instead, I need to display a message I control and divert the script to do something else.
I copied the sample code (for the ‘application.getLastErrorCode();’ function) but it did nothing to allow me to control the error message.
Could you please give a sample script for accomplishing the above? That is, generate an error (use an undefined variable, for example) and then trap the error and display a custom message.
Am I even correct that, like FMP, for any error that could happen in a script I can trap for it and display a message?
application.setErrorCapture only detects runtime errors
like for instance bad queries to the database.
The error you are trying to capture is a javascript error inside your script.
Your user will never encounter such an error, unless you decide to leave your script as is, which doesn’t make sense, as it won’t run in the first place. Use the debugger to validate your scripts.