0

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.

neerajPK
  • 293
  • 1
  • 4
  • 17

2 Answers2

1

In this post you can find list of possible error codes, which will help you to categorize it using your specific error strings: Undocumented NSURLErrorDomain error codes (-1001, -1003 and -1004) using StoreKit

Community
  • 1
  • 1
Ilya K.
  • 938
  • 6
  • 16
0

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];
neerajPK
  • 293
  • 1
  • 4
  • 17