THROW

Throw an exception

WSupported on Windows
USupported on Unix
VSupported on OpenVMS
NSupported in Synergy .NET
THROW [object_handle]

object_handle

(optional) An object handle derived from System.Exception.

The THROW statement unwinds the stack automatically until a handler that handles the type of exception thrown is located. This allows errors that occur deep within a series of routine calls to be handled at a higher level by a single exception handler.

The THROW statement adds a line of the format

"   at namespace.class.member in filename:line line_num"

to the StackTrace property of the exception for each nested level on the unwind stack. The topmost line indicates the line where the THROW occurred.

You can rethrow the most recently caught exception and maintain the exception’s original context by using the THROW command within your CATCH block without specifying object. You cannot rethrow outside of a CATCH block.

For example, the following will rethrow the caught exception:

catch (e, @Exception)
begin
  throw
end

The example below throws the object returned by “new Exception(“My Error”)”.

throw new Exception("My Error")