How to debug terminate_handler unexpectedly threw an exception?

2k views Asked by At

I'm working on a project which uses ASIFormDataRequest to access the network and here is my code:

NSMutableString *url = [[NSMutableString alloc] initWithCapacity:10];
[url appendString:LOGINURL];
NSURL* nurl = [NSURL URLWithString:url];

ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:nurl];
request.timeOutSeconds = 30;
__weak ASIFormDataRequest *weakRequest = request;
[request setCompletionBlock:^ {
    NSString* str = [weakRequest responseString];
    block(str);
}];
[request setFailedBlock:failBlock];
[request startAsynchronous];

It works fine when the network is good. But if the network is terrible, then the requests always fail and the app would CRASH with this message:

libc++abi.dylib: terminate_handler unexpectedly threw an exception

I don't know why and even don't know how to debug it since there is no other crash message. How to debug it?

0

There are 0 answers