webView keeps showing -999 error message box for iOS devices

When testing webView in iOS device, it shows an error message box now and then,

the operation couldn’t be completed. (NSURLerrorDomain error -999.)

After searching the cause online, error -999 means

“Returned when an asynchronous load is canceled. A Web Kit framework
delegate will receive this error when it performs a cancel operation on a
loading resource. Note that an NSURLConnection or NSURLDownload delegate
will not receive this error if the download is canceled.”

And all suggestions are to ignore error -999 because it is more like a information instead of an error. 

Could Corona SDK ignore this error instead of poping up an error message box?

It’s my fault. Thanks for Corona’s help, I found out that the pop up error message is actually generated from my code. I copied the example code from Corona document without paying enough attention:

local function webListener( event ) if event.url then print( "You are visiting: " .. event.url ) end if event.type then print( "The event.type is " .. event.type ) -- print the type of request end if event.errorCode then native.showAlert( "Error!", event.errorMessage, { "OK" } ) end end

There is a showAlert in the errorCode case!

FYI, error -999 can be ignored:

https://discussions.apple.com/thread/1727260

It’s my fault. Thanks for Corona’s help, I found out that the pop up error message is actually generated from my code. I copied the example code from Corona document without paying enough attention:

local function webListener( event ) if event.url then print( "You are visiting: " .. event.url ) end if event.type then print( "The event.type is " .. event.type ) -- print the type of request end if event.errorCode then native.showAlert( "Error!", event.errorMessage, { "OK" } ) end end

There is a showAlert in the errorCode case!

FYI, error -999 can be ignored:

https://discussions.apple.com/thread/1727260

Thanks for your forum thread. I wish this info was provided in the API page as a Gotcha perhaps.

Did you keep the check for event.errorCode in your listener and simply code it to ignore 999 or did you get rid of the check altogether. I’m inclined towards leaving the check for event.errorCode in there for other possible errors. Thoughts?

Hi guys,

Would it help if I added this to the API documentation?

“On iOS, when checking for event.errorMessage in a web view listener, you may occasionally receive an error message such as “NSURLerrorDomain error -999”. This is returned when an asynchronous load is cancelled. A Web Kit framework delegate will receive this error when it performs a cancel operation on a loading resource, however a NSURLConnection or NSURLDownload delegate will not receive this error if the download is cancelled. Generally speaking, this error can be ignored.”

Does that describe the issue accurately?

Brent

Hi Brent. This would be good. Perhaps one last sentence added to cater for the less technical amongst us ;-)… something like :

“This event / error may occur if a link in webView is clicked while the webView is still in the process of loading the first page etc”.

Thanks for your forum thread. I wish this info was provided in the API page as a Gotcha perhaps.

Did you keep the check for event.errorCode in your listener and simply code it to ignore 999 or did you get rid of the check altogether. I’m inclined towards leaving the check for event.errorCode in there for other possible errors. Thoughts?

Hi guys,

Would it help if I added this to the API documentation?

“On iOS, when checking for event.errorMessage in a web view listener, you may occasionally receive an error message such as “NSURLerrorDomain error -999”. This is returned when an asynchronous load is cancelled. A Web Kit framework delegate will receive this error when it performs a cancel operation on a loading resource, however a NSURLConnection or NSURLDownload delegate will not receive this error if the download is cancelled. Generally speaking, this error can be ignored.”

Does that describe the issue accurately?

Brent

Hi Brent. This would be good. Perhaps one last sentence added to cater for the less technical amongst us ;-)… something like :

“This event / error may occur if a link in webView is clicked while the webView is still in the process of loading the first page etc”.