The format of the throw statement are:
throw expression ;
It throws an instance of the error class to signal that an exception has occurred. As a result, execution control goes back the call history in order to find the nearest try statement surrounding the throw statement.
When it finds the appropriate try statement, it jumps control to the beginning of the section if there is a catch section, or to the next statement of the endtry if it doesn't.
If no such try statement is found, an exception arrives at the application and the Rice program stops executing.
A keyword that indicates that it is a throw statement.
The instance that the expression generates is attached to the instance of the error class. If you don't need the instance, you can omit it.
If the throw statement has no expression, the ExceptionData getter of the error class is an instance of the uninitialized proxy class.
If the throw statement has an expression, the ExceptionData getter of the error class is an instance of the proxy class initialized with the expression.
The exception is that if the expression is the reserved variable __error, __error is rethrown.
The end of a throw statement is represented by a semicolon.
open method void someMethod()
ex.someMethod(); // It throws an exception.
string mess = __error.ExceptionData.Entity; // "exception"
An exception is thrown from the someMethod() method. Since the throw statement has an string literal, the ExceptionData getter of the thrown instance is initialized with a string.
The exception is caught in the try statement surrounds the method call. Execution control is moved because the try statement has a catch section.
Thrown instance is stored to the reserved variable __error when execution control is moved to the catch section.