尝试Catch语句realBasic

时间:2013-07-09 17:26:30

标签: basic realbasic xojo

我试图在try catch中包含简单的语句。问题是我能够找到的所有示例都谈到了预定义的错误。

我需要一个通用错误,类似于C#中的try / catch。

1 个答案:

答案 0 :(得分:2)

对于通用的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]