|
|
Other versions: 1.0
Exception Handling in DaoDao exceptions are organized into hierarchal structured classes. The base class is Exception ,
class Exception
Currently supported classes are the following:
{ routine Exception( content='' ){ Content = content } protected var Rout = ''; var File = ''; var FromLine = 0; var ToLine = 0; public var Name = 'Exception'; var Content : any = 'undefined exception'; }
Any running time error will raise a proper exception instance. User-defined exception can be raised by using raise statement. Exceptions can be rescued by a block of code after a rescue statement The exception handling syntax is the following:
stmt_tryrescue ::=
where expr is a list of exception class(es).
If there is no expr following rescue , any exception will be rescued.
There can be multiple rescue statements in a try-rescue block.
The raised exceptions will be checked against the exception classes presented in
each of the rescue statement, if there is a matching, the corresponding code
block is executed, and the rescued exceptions can be accessed in a global list named
exceptions . In the same try-rescue block different rescue statements
can be used to handle different exceptions. 'try' '{' stmt_block { '}' 'rescue' [ '(' expr ')' ] '{' stmt_block }* '}' If all rescue statements have been tried and there is still un-rescued exception(s), the current function is aborted and the exceptions(s) is raised to its caller, if there is; otherwise, the program is aborted with the values of the un-rescued exceptions printed out. In a rescue statement, one may modify exection condition, and use retry to invoke the codes in try block. Examples,
try{
raise Exception.Error( "error test" ), Exception.Warning( "warning test" ), Exception( "exception" ); }rescue( Exception.Error, Exception.Warning ){ stdio.println( exceptions ); }rescue{ stdio.println( "rescued" ); }
view count 562 times
created at 2009-02-28, 16:43 GMT modified at 2009-09-18, 06:41 GMT |
fu: Many thanks (Jul.04,04:29) klabim: fixed Hi, great, now my test works now :- ). (Jun.30,17:51) Nightwalker: Few suggestions (Jul.03,14:37) |