Is there a proper way to catch exceptions within block code?
I got the following code:
void(^callback(int) = ^(int respond){
[self DoSomethingWithRespond:respond]; //this throws an exception
};
-(void)DoSomethingWithRespond:(int)respond{
if(respond == 400){
NSException *exception = [NSException
exceptionWithName:@"Failed"
reason:logMessage
userInfo:nil];
@throw exception
}
}
The callback methods gets called from another thread. If the respond is equal to 400 the DoSomethingWithRespond
method will throw an exception.
@try {
<#statements#>
}
@catch (NSException *exception) {
<#handler#>
}
@finally {
<#statements#>
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With