Purpose of this chapter.
We will learn about the throw statement.
Throw of the exception.
The throw statement throws an instance of the error class in order to notify that an exception occurred. As a result, the execution control go back the call history in order to find the nearest try statement that encloses the throw statement.
When the try statement is found. If a catch clause is exist, the control will move to the first statement in the catch clause. If a catch clause is not exist, the control will move to the next statement of endtry.
When the try statement is not found. The exception notice reaches to the application. And, Rice program will stop the running.
A throw statement is the following format.
throw expression ;
The 'throw' keyword indicates that this statement is a throw statement.
An Instance that is generated by this expression will be attached to the instance of the error type. it can be omitted if the instance is not required.
If there is no expression in the throw statement, the ExceptionData getter of the instance that is thrown is an instance of a proxy class that is not initialized.
If there is an expression in the throw statement, the ExceptionData getter of the instance that is thrown is an instance of a proxy class that is initialized by the expression.
However, if the expression is the __error (reserved variable). The __error is thrown again.
The end of the throw statement.
The end of the throw statement is represented by a semicolon.