How i finding Internate network error using Try..........Catch in iphone?
<p>I developing an application in which i calling web services on iphone. I want to implement Try.......Catch in that code for catching internet and GPRS connection error.The code is as follow,</p>

<pre><code>NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setURL:[NSURL URLWithString:mainURL5]];
[request setHTTPMethod:@"POST"];

NSHTTPURLResponse* urlResponse = nil;  
NSError *error = [[[NSError alloc] init] autorelease];  
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&amp;urlResponse error:&amp;error];  
result5 = [[NSMutableString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];  
</code></pre>

<p>I was using Try......catch but it didn't work that code as follows,</p>

<pre><code>@try
{
//prepar request
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setURL:[NSURL URLWithString:mainURL5]];
[request setHTTPMethod:@"POST"];

NSHTTPURLResponse* urlResponse = nil;  
NSError *error = [[[NSError alloc] init] autorelease];  
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&amp;urlResponse error:&amp;error];  
result5 = [[NSMutableString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
}
@catch(NSException * e)
{
    [clsMessageBox ShowMessageOK:@"some text" :[e reason]];
}
</code></pre>
