Service Studio 6.0 Help
Handling JavaScript Errors
The JavaScript errors are handled by adding JavaScript functions to your application and registering them as error handler functions.
Error Handler Function
Write your error handling business logic in the JavaScript function which has to have the following signature:
function <ErrorHandlerFunctionName>( event, exception [, errorCode] [, origin] )
The arguments are:
event: identifies the jQuery event;
exception: is the JavaScript exception instance that raised the error. For more details about the error use the exception.name and exception.message properties;
errorCode: an integer that identifies the type of error. This argument is optional;
origin: the JavaScript function where the error was trapped. This argument is optional.
By default, the Agile Platform provides you a basic error
handler function called OsAlertExceptionHandler
which displays an alert box with information about the error.
Predefined Error Codes
When implementing the error handling business logic in your function you may use the Agile Platform predefined error codes:
osjs.osErrorCodes.UserJavascriptError: this error occurs during the execution of a JavaScript in the OML or a refresh of an unescaped expression with '<script>' tags;
osjs.osErrorCodes.ConnectionError: this is a connection error and occurs in the beginning or during an Ajax request to the server;
osjs.osErrorCodes.SystemJavascriptError: this error occurs when an unexpected exception is raised while executing an OutSystems' Ajax JavaScript.
Register an Error Handler Function
To set your JavaScript function for error handling you must register it. For that, add the following JavaScript to your application:
OsRegisterExceptionHandler(<ErrorHandlerFunctionName>)
You may register multiple functions to handle errors. All
the registered error handler functions are executed when a JavaScript
error occurs.
See also