Loading...
Searching...
No Matches
Exception Handling

Exceptions are errors that can only be handled using a try catch block. Any exception that is thrown in a try block will immediately cause execution of that thread to begin with the first statement of the catch block, regardless of the position of the program pointer of the running thread, even if nested function or object method calls have been made.

Exceptions can be thrown by the Qore system for a number of reasons, see the documentation for each function and object method for details.

Programmers can also throw exceptions explicitly by using the throw and rethrow statements.

Information about the exception, including the context in which the exception occurred, is saved in the exception hash, which can be retrieved by using a parameter variable in the catch block.

The exception hash is defined in the ExceptionInfo hashdecl.

System exceptions always throw at least 2 values, populating the `"err"` and `"desc"` keys of the exception hash, giving the exception string code and the exception description string, respectively, and occassionally, depending on the function, the `"arg"` key may be populated with supporting information. User exceptions have no restrictions, any values given in the throw statement will be mapped to exception keys as per the table above.

See the on_exit, on_success statement, and on_error statement for statements that allow for exception-safe and exception-dependent cleanup in Qore code.

Classes that assist in exception-safe lock handling are the AutoLock class, the AutoGate class, the AutoReadLock class, and the AutoWriteLock class.

Note
  A maximum limit of 20 exceptions can be raised at any time; excess exceptions over this limit will be ignored.