3

An exception is thrown in my app and I'm trying to handle it here. The intent is to make a call to our sever and this is not successful. I've isolated the server call in a try/catch statement to see if another exception is thrown but as you can see from my log no additional exception is thrown. Is it possible to send web requests from an exception handler or does the process get interrupted for some reason?

void uncaughtExceptionHandler(NSException *exception) {
    [Flurry logError:@"Uncaught" message:@"Crash!" exception:exception];
    NSLog(@"Exception: %@", exception);
    NSArray *stack = [exception callStackReturnAddresses];
    NSLog(@"Stack trace: %@", stack);
    NSString *stackTrace = [stack description];
    @try {
        NSString *domain = @"blabla.mydomain.com";
        NSURL *url2 = [NSURL URLWithString: [NSString stringWithFormat: @"http://%@/error/SendExceptionDetailsToStaff", domain]];
        ASIFormDataRequest *request2 = [ASIFormDataRequest requestWithURL:url2];
        [request2 setPostValue: stackTrace forKey:@"stackTrace"];
        [request2 setPostValue: [[UIDevice currentDevice] model] forKey:@"device"];
        [request2 setPostValue: [[UIDevice currentDevice] systemVersion] forKey:@"osVersion"];
        [request2 startAsynchronous];     
    }
    @catch (NSException * e) {
        NSLog(@" Request Exception: %@", e);
    }
    NSLog(@"yooooo"); 
}


log:
2013-01-10 15:16:20.761 myApp[4653:c07] Stack trace: (0x28fa012 0x1b6ce7e 0x2982fb1 0x8c601 0xc1f753 0xc1fa7b 0xc2d590 0xc355bd 0xc35eab 0xc35fc9 0xc36055 0xd3b3ab 0xb8c92d 0x1b806b0 0x7409fc0 0x73fe33c 0x73fe150 0x737c0bc 0x737d227 0x737d8e2 0x28c2afe 0x28c2a3d 0x28a07c2 0x289ff44 0x289fe1b 0x2b327e3 0x2b32668 0xb3c65c 0x216d 0x20a5)
2013-01-10 15:16:20.761 myApp[4653:c07] yooooo
secretformula
  • 6,414
  • 3
  • 33
  • 56
Rammeln
  • 168
  • 1
  • 7

2 Answers2

1

Ended up solving my own problem. The issue was that the asynchronous web request would get interrupted before it could finish. Making it synchronous and staying on the same thread solves the problem.

[request2 startSynchronous];
Rammeln
  • 168
  • 1
  • 7
0

Try setting an exception breakpoint (instructions here: http://developer.apple.com/library/ios/#recipes/xcode_help-breakpoint_navigator/articles/adding_an_exception_breakpoint.html) - you should get a more descriptive debug message.

Jacek Lampart
  • 1,741
  • 13
  • 25