我正试图在try-catch中封装一个简单的语句。问题是,我能找到的所有例子都谈到了预定义的错误。
我需要一个通用错误,类似于C#中的try/catch。
对于一般的try-catch,您可以这样做:
try
...put some code here
catch
...do something for ANY exception here.
finally
...code here that runs IF an exception occurs
end try
catch部分有一些可选参数来捕获某些类型的错误(您已经看到的示例)。第一段给出的定义http://docs.xojo.com/index.php/Try
Try
// Your code
Catch [ErrorParameter] [As ErrorType]
//exception handlers
[ Finally ]
//code that executes even if runtime exceptions were raised
End [Try]