2010-07-07 89 views
0

嗨,我使用ScriptDebugDelegate通知我exceptionWasRaised函数中发生异常时。WebKit如何处理异常

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

感谢 ASH

回答

1

如果您知道哪里出现异常时,您可以使用一个try/catch与catch块中没有代码行

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

你甚至可以通过使用特定的过滤它要喜欢CustomException异常类型:

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

什么会导致任何MyCustomException被忽略,和所有其他的火警d。

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