From 978e33e8c5752e172689ff2fc4512f94eaee7791 Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Wed, 15 Mar 2023 17:23:11 +0800 Subject: [PATCH] iOS: fix js exception cause native block --- doric-iOS/Pod/Classes/Util/DoricAsyncResult.m | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/doric-iOS/Pod/Classes/Util/DoricAsyncResult.m b/doric-iOS/Pod/Classes/Util/DoricAsyncResult.m index 04652cb1..cecfbe8c 100644 --- a/doric-iOS/Pod/Classes/Util/DoricAsyncResult.m +++ b/doric-iOS/Pod/Classes/Util/DoricAsyncResult.m @@ -86,6 +86,13 @@ - (id)waitUntilResult { self.resultCallback = ^(id r) { 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); return self.result; } @@ -101,6 +108,13 @@ - (id)waitUntilResult:(id (^)(id result))transformer { ret = transformer(r); 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); return ret; }