Search code examples
ioserror-handlinguiwebviewwebkit

How to catch WebKit Errors


I wonder how i can catch and handle WebKit Errors in my iPad App. I found no information about ErrorDomain and ErrorCodes up till now. Is this a miracle?

This is what i see from time to time at the console in Xcode during testing on device (iPad2, iOS 5.0.1).

WebKit discarded an uncaught exception in the webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame: delegate: <(null)> A route has already been registered for class 'Publication' and HTTP method 'ANY'

How can i catch WebKit Errors? This Error raises during an alert(); in JS within the HTML Page that's loaded in a UIWebView.


Solution

  • I am not sure but maybe the:

    - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
    

    could put some light on that issue (that's UIWebViewDelegate). Set the delegate and implement this method. Print the error description to the console and check it.