Closed imunique-ZJ closed 6 years ago
Hi, I'd like to use "recover" to catch errors and do some fallback function for specific error code. But I got errors in the recover block:
Return type 'NSError *' must match previous return type 'FBLPromise<NSMutableArray *> *' when block literal has unspecified explicit return type
Here's my sample.
[self doAWork] .recover(^(NSError *error) { if (error.code == USE_FALLBACK) { return [self doFallback]; } else { return error; // this will cause compile errors } }) .then(^id(NSMutableArray *values) { return [self doBWork:values]; }).catch(^(NSError *error) { NSLog("something wrong. error= %@", error); });
Is it possible to return error in "recover" block? Or are there any other ways I can try? Thanks.
Don’t forget the recovery block prototype must have a return type of id. It’s missing in your snippet, so the compiler has valid complains. Use this: .recover(^id(NSError *error) {
.recover(^id(NSError *error) {
Oh, my bad. Thanks a lot. :)
Hi, I'd like to use "recover" to catch errors and do some fallback function for specific error code. But I got errors in the recover block:
Return type 'NSError *' must match previous return type 'FBLPromise<NSMutableArray *> *' when block literal has unspecified explicit return type
Here's my sample.
Is it possible to return error in "recover" block? Or are there any other ways I can try? Thanks.