iOS: fix js exception cause native block

This commit is contained in:
pengfei.zhou 2023-03-15 17:23:11 +08:00 committed by jingpeng
parent 19fc1fdebe
commit 978e33e8c5

View File

@ -86,6 +86,13 @@ - (id)waitUntilResult {
self.resultCallback = ^(id r) { self.resultCallback = ^(id r) {
dispatch_semaphore_signal(semaphore); dispatch_semaphore_signal(semaphore);
}; };
void (^originExceptionCallback)(NSException *e) = self.exceptionCallback;
self.exceptionCallback = ^(NSException * e) {
if(originExceptionCallback){
originExceptionCallback(e);
}
dispatch_semaphore_signal(semaphore);
};
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER); dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
return self.result; return self.result;
} }
@ -101,6 +108,13 @@ - (id)waitUntilResult:(id (^)(id result))transformer {
ret = transformer(r); ret = transformer(r);
dispatch_semaphore_signal(semaphore); dispatch_semaphore_signal(semaphore);
}; };
void (^originExceptionCallback)(NSException *e) = self.exceptionCallback;
self.exceptionCallback = ^(NSException * e) {
if(originExceptionCallback){
originExceptionCallback(e);
}
dispatch_semaphore_signal(semaphore);
};
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER); dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
return ret; return ret;
} }