categorise UIWebView errors and display on iphone app?-Record and share programming errors
is their any category for UIWebView possible errors? in my app i need to display the actual error occurred while loading url. i can print the error in didFailLoadWithError method , but in gives a long description about the error something like
didFailLoadWithError Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found." UserInfo=0x895fb10 {NSErrorFailingURLStringKey=https://mobilelogin.bwanet.ca/mdninput.html?csphostid=J13y8E9t000Mb3ZK00001H7R, NSErrorFailingURLKey=https://mobilelogin.bwanet.ca/mdninput.html?csphostid=J13y8E9t000Mb3ZK00001H7R, NSLocalizedDescription=A server with the specified hostname could not be found., NSUnderlyingError=0x8c68f20 "A server with the specified hostname could not be found."}
how will i categorise these possible errors and i want to display it like “specified hostname could not be found” “url timeout error” etc.
-
okay, in didFailWithError method
if (error.code==NSURLErrorTimedOut) { errorReason=@"URL Time Out Error "; } else if (error.code==NSURLErrorCannotFindHost) { errorReason=@"Cannot Find Host "; } else if (error.code==NSURLErrorCannotConnectToHost) { errorReason=@"Cannot Connect To Host"; } else if (error.code==NSURLErrorNetworkConnectionLost) { errorReason=@"Network Connection Lost"; } else if (error.code==NSURLErrorUnknown) { errorReason=@"Unknown Error"; } else { errorReason=@"Loading Failed"; } UIAlertView *errorAlert=[[UIAlertView alloc]initWithTitle:errorReason message:@"Redirecting to the server failed. do you want to EXIT the app" delegate:self cancelButtonTitle:@"EXIT" otherButtonTitles:@"RELOAD", nil]; [errorAlert show]; [errorAlert release];
Originally posted 2013-08-24 14:13:32.