Exception Class Return Values

The following table lists the Exception class return values that indicate the action the system takes.

Return Value Global Constant Action
0 Ex_Continue Resumes execution from the next expression after the expression that caused the exception.
    Use this return mode only in circumstances when you are certain that continuing the code execution will still be correct after ignoring the exception.
    For lock exceptions, use this return mode only if the lock has been successfully retried. If the exception occurred while updating, ensure that the transaction has not been aborted by the exception handler.
    Continuable exceptions can be ignored (that is, the Ignore button is enabled) when production mode is disabled. The Ignore button is always disabled when production mode is enabled for the database. (For details, see "Running JADE Production Mode Databases", in Chapter 1 of the JADE Runtime Application Guide.)
1 Ex_Abort_Action Causes the currently executing methods to be aborted. The execution stack is stripped back and the application reverts to an idle state in which it is waiting for user input or some other Windows event, in most cases.
    If there is a transaction in progress, this is not aborted. An abortTransaction instruction must be explicitly coded within the exception handler if the database transaction in progress is also to be aborted.
2 Ex_Resume_Next Passes control back to the method that armed the exception handler. Resumes from the next statement after the evaluation of the method call or expression in which the exception occurred.
   

You cannot resume from global exception handlers. Using this value for a global exception handler is equivalent to returning the Ex_Abort_Action value.

If an exception occurs during evaluation of a return expression, when the exception handler returns, the executing method is terminated (in accordance with executing a return instruction) and the default value of the return type is returned.

-1 Ex_Pass_Back Passes control back to the prior local exception handler for this type of exception or if a local handler is not found, a global exception handler for this type of exception.

When you have created an exception handler, you must arm it or tell the system to invoke that method in case of an exception. The following syntax sets the current exception handler to method-call-expression.

on exception-class do method-call-expression

The exception-class identifier is the Exception class or one of its subclasses.

If a global exception handler is armed on a serverExecution method and returns Ex_Abort_Action (or Ex_Resume_Next) when an exception occurs, exception 1242 (that is, a method executing in another node was aborted) is raised on the client node.

The following is an example of a method that arms an exception handler.

work(currentObject: Object);
vars
    fileSave : CMDFileSave;
    file     : File;
begin
    on FileException do fileExceptionHandler(exception);
    if fileSave.open = 0 then
        create file;
        file.mode        := File.Mode_Output;
        file.allowCreate := false;
        file.fileName    := fileSave.fileName;
        currentObject.saveToFile(file);
        delete file;
    endif;
end;