Throws an exception from a Try block to a Catch exception handler.
command explicitly issues an exception from within a block of code defined by a Try
command. Issuing a Throw
transfers execution from the Try
block to the corresponding Catch
is used to issue an explicit exception. Caché issues an implicit exception when a runtime error occurs. A runtime error generates an exception object which it throws to a Catch
Without an argument
With an argument
transfers error processing to the corresponding Catch
error handler. No object is pushed on the stack, but the %New() method is called.
specifies a user-defined object reference, which it throws to the Catch
command, pushing it on the execution stack. The calling of the %New() method is optional.
A user-defined object reference (oref). For example, Throw ##class(%Exception).%New()
. The creation and population of this exception object is the responsibility of the programmer.
The following example shows an argumentless Throw
PRINTLN "about to divide by ",x
PRINTLN "Success: the result is ",a
PRINTLN "this is the exception handler"
PRINTLN "Error number: ",Err.Number
PRINTLN "Error is: ",Err.Description
PRINTLN "Error code: ",myvar.Code
PRINTLN "this is where the code falls through"