After the keyword
throw, you have an expression. This expression can evaluate to any value, of any data type. You might want to throw an error code, which may be a
number data type. Or you might want to throw an error message, which would be a
string data type.
Error class and its subclasses.
Here is a real example:
In the above example, the
throw statement executes based on the
if condition that proceeds it. If the condition evaluates to
Error object is created.
catch clause of the
If an exception handler is never found, then the exception is treated as an error and is reported to the user.
Here is an example of a
throw statement inside of the
try block of a