WebKit如何处理异常

时间:2010-07-07 17:00:43

标签: webkit

嘿,我正在使用ScriptDebugDelegate在exceptionWasRaised函数中发生异常时通知我。

但是,我想知道如何忽略异常,即。只需跳过通常会触发异常的代码行。

由于 ASH

1 个答案:

答案 0 :(得分:1)

如果您知道发生异常的行,您可以使用catch块中没有代码的try / catch

@try {
    //my code that throws exception
} @catch ( NSException *e ) {
}

您甚至可以使用您想要的CustomException特定异常类型来过滤它:

@try {
    //my code that throws exception
} @catch ( MyCustomException *e ) {
}

什么会导致任何MyCustomException被忽略,而其他所有被忽略。

注意:使用它仅用于测试和调试是很重要的,因为空捕获始终是错误的。