I'm trying to figure out the most appropriate way to handle errors that can occur when loading pages in a UIWebView
.
I'd like to alert the user if I notice a network related issue, or a server related issue. I am unable to find any details on the specific error codes to check for. This is what I have right now:
NSInteger errorCode = [error code];
NSString* title = nil;
NSString* message = nil;
if (errorCode == NSURLErrorNetworkConnectionLost || errorCode == NSURLErrorNotConnectedToInternet) {
title = @"Error";
message = @"The network connection appears to be offline.";
}
if (errorCode == NSURLErrorTimedOut || errorCode == NSURLErrorBadServerResponse) {
title = @"Error";
message = @"There was an error loading the request. Please try again later.";
}
if (title != nil) {
UIAlertView* alert = [[UIAlertView alloc] initWithTitle:title message:message delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
alert.tag = TAG_WEB_ERROR;
[alert show];
}
Am I checking for the correct error codes? Any thoughts on a better way to check for and handle potential errors?