|
|
Other versions: 1.0
道语言异常处理道异常类被组织为树形结构,其基类是 Exception:
class Exception
目前支持的类包括:
{ 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'; }
任何运行时错误将抛出异常类实例。 程序也可在任何地方使用raise语句抛出异常类实例。 被抛出的异常可由rescue语句扑获,然后进行处理, 相关语法是:
stmt_tryrescue ::=
这里expr可以为空,或是一个或多个异常类。
如果rescue后没有expr,所有异常都将被扑获。
每个try-rescue块里,可以有多个rescue语句,
每个rescue语句都将被检测是否可以扑获到异常,
如果扑获到了,相应的语句块将被执行,
并且被扑获的异常将可用全局变量exceptions列表访问。'try' '{' stmt_block { '}' 'rescue' [ '(' expr ')' ] '{' stmt_block }* '}' 如果所有rescue语句都被检测了,但还剩没有扑获的异常, 那么当前运行函数将中止,并将异常抛给起调用者。 如果当前函数没有调用者,那么程序将被中止, 并打印异常信息。 在一个rescue语句块里,在修改某些运行条件后,retry可用来重新尝试 执行try语句块里的代码。 例子,
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 359 times
created at 2009-03-02, 17:07 GMT modified at 2009-09-18, 06:40 GMT |
fu: Fixed and updated There was a minor bug in storing returned value in the DaoVmProcess structure. Now it is fixed and up ... (Sep.07,23:43) klabim: ... Ok, I found it. It can be so easy by reading the documentation :- ). I have overseen the keyword glob ... (Aug.21,18:09) klabim: returning a string from function to c++ code! Hi, I run in some trouble while calling a dao function from the c++ code. The dao function should re ... (Sep.07,19:44) klabim: sharing vars between scripts Hi, how can I share a variable between 2 scripts in an embedded environment? For example: script 1: ... (Aug.21,17:55) |