throw object
Throws an exception with the given object. If the exception is not caught, the script is terminated and the object is printed through the output channel.
try { .... } catch(object) { .... }
Catches exceptions with the given object type that occur between the try { ... } brackets. When ... is given for the object type, all remaining exception types are caught.
Example:
try {
if (i == 0)
throw 1;
if (i == 2)
throw "Error";
}
catch(int a)
{
print(message("Exception %x%!") << a);
}
catch(string s)
{
print(s);
}
See also:
message, print ► latest
version online