throw — Throws a user-defined exception or rethrows a caught exception.
throw( : : Exception : )
With the help of the operators
throw it is possible to implement a dynamic exception handling
in HDevelop, which is comparable to the exception handling in C++
and C#. The basic concepts of the exception handling in HDevelop are
also described at the operators
dev_set_check as well as in the “HDevelop User's Guide”.
throw provides an opportunity to throw an exception
from an arbitrary place in the program.
This exception can be caught by the
catch operator of a
By this means the developer is able to define his own specific error or
exception states, for which the normal program execution is aborted in
order to continue with a specific cross-procedure exception handling,
e.g., for freeing resources or restarting from a defined state.
In such a user-defined exception a nearly arbitrary tuple can be thrown
Exception parameter, merely the first element of the tuple
should be set to a user-defined error code >= 30000.
In addition, with the help of the operator
throw it is possible to
rethrow an exception that was caught with the operator
This may be sensible, for instance, if within an inner
endtry block (e.g., within an external
procedure) only specific exceptions can be handled in an adequate way and
all other exceptions must be passed to the caller, where they can be caught
and handled by an outer
For rethrowing a caught exception, it is possible to pass the
Exception tuple that was caught by the
directly to the
Exception parameter of the
Furthermore, it is possible to append arbitrary (but no iconic) user
data to the
Exception tuple, that can be accessed after catching
the exception as 'user_data' with the operator
try ... catch (Exception) ... UserData := ... throw ([Exception, UserData]) endtry
The export of the operators
throw is not supported for the language C, but only for the
languages C++, C# and VisualBasic/.NET.
Only the latter support throwing exceptions across procedures.
→(integer / string)
Tuple returning the exception data or user defined error codes.
If the values of the specified parameters are correct,
throw (as operator) returns 2 (H_MSG_TRUE). Otherwise an
exception is raised and an error code returned.