From 3b0a2451294d8841913b1fdf4dbf2f1258835964 Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Sat, 7 Mar 2020 10:38:42 +0800 Subject: [PATCH] feat:Android and iOS monitor use DoricContext as parameter --- .../java/pub/doric/DoricNativeDriver.java | 34 +++++++++++++------ .../main/java/pub/doric/DoricRegistry.java | 4 +-- .../main/java/pub/doric/IDoricMonitor.java | 6 ++-- .../java/pub/doric/engine/DoricJSEngine.java | 20 ++++++----- .../bridge/DoricBridgeExtension.java | 4 +-- .../doric/extension/bridge/DoricPromise.java | 4 +-- .../java/pub/doric/plugin/ShaderPlugin.java | 6 ++-- .../main/java/pub/doric/shader/ImageNode.java | 2 +- doric-iOS/Devkit/Classes/DoricDebugDriver.m | 12 +++---- doric-iOS/Pod/Classes/DoricContext.m | 8 ++--- doric-iOS/Pod/Classes/DoricContextManager.m | 3 +- doric-iOS/Pod/Classes/DoricDriverProtocol.h | 2 -- doric-iOS/Pod/Classes/DoricMonitorProtocol.h | 3 +- doric-iOS/Pod/Classes/DoricNativeDriver.m | 12 +++---- doric-iOS/Pod/Classes/DoricRegistry.m | 8 ++--- doric-iOS/Pod/Classes/Engine/DoricJSEngine.m | 6 ++-- .../Classes/Extension/DoricBridgeExtension.m | 2 +- doric-iOS/Pod/Classes/Plugin/DoricPromise.m | 4 +-- .../Pod/Classes/Plugin/DoricShaderPlugin.m | 2 +- 19 files changed, 73 insertions(+), 69 deletions(-) diff --git a/doric-android/doric/src/main/java/pub/doric/DoricNativeDriver.java b/doric-android/doric/src/main/java/pub/doric/DoricNativeDriver.java index d69f8638..c39c06fb 100644 --- a/doric-android/doric/src/main/java/pub/doric/DoricNativeDriver.java +++ b/doric-android/doric/src/main/java/pub/doric/DoricNativeDriver.java @@ -59,13 +59,33 @@ public class DoricNativeDriver implements IDoricDriver { @Override public AsyncResult invokeContextEntityMethod(final String contextId, final String method, final Object... args) { + final AsyncResult asyncResult = new AsyncResult<>(); final Object[] nArgs = new Object[args.length + 2]; nArgs[0] = contextId; nArgs[1] = method; if (args.length > 0) { System.arraycopy(args, 0, nArgs, 2, args.length); } - return invokeDoricMethod(DoricConstant.DORIC_CONTEXT_INVOKE, nArgs); + invokeDoricMethod(DoricConstant.DORIC_CONTEXT_INVOKE, nArgs).setCallback(new AsyncResult.Callback() { + @Override + public void onResult(JSDecoder result) { + asyncResult.setResult(result); + } + + @Override + public void onError(Throwable t) { + asyncResult.setError(t); + getRegistry().onException( + DoricContextManager.getContext(contextId), + t instanceof Exception ? (Exception) t : new RuntimeException(t)); + } + + @Override + public void onFinish() { + + } + }); + return asyncResult; } @Override @@ -91,14 +111,6 @@ public class DoricNativeDriver implements IDoricDriver { } } - private String sourceWithContextId(String contextId) { - DoricContext context = DoricContextManager.getContext(contextId); - if (context == null) { - return "Unknown:" + contextId; - } - return context.getSource(); - } - @Override public AsyncResult createContext(final String contextId, final String script, final String source) { return AsyncCall.ensureRunInHandler(mJSHandler, new Callable() { @@ -108,7 +120,7 @@ public class DoricNativeDriver implements IDoricDriver { doricJSEngine.prepareContext(contextId, script, source); return true; } catch (Exception e) { - doricJSEngine.getRegistry().onException(sourceWithContextId(contextId), e); + doricJSEngine.getRegistry().onException(DoricContextManager.getContext(contextId), e); doricJSEngine.getRegistry().onLog(Log.ERROR, String.format("createContext %s error is %s", source, e.getLocalizedMessage())); return false; } @@ -125,7 +137,7 @@ public class DoricNativeDriver implements IDoricDriver { doricJSEngine.destroyContext(contextId); return true; } catch (Exception e) { - doricJSEngine.getRegistry().onException(sourceWithContextId(contextId), e); + doricJSEngine.getRegistry().onException(DoricContextManager.getContext(contextId), e); doricJSEngine.getRegistry().onLog(Log.ERROR, String.format("destroyContext %s error is %s", contextId, e.getLocalizedMessage())); return false; } diff --git a/doric-android/doric/src/main/java/pub/doric/DoricRegistry.java b/doric-android/doric/src/main/java/pub/doric/DoricRegistry.java index 01e63023..57ab1dfe 100644 --- a/doric-android/doric/src/main/java/pub/doric/DoricRegistry.java +++ b/doric-android/doric/src/main/java/pub/doric/DoricRegistry.java @@ -162,9 +162,9 @@ public class DoricRegistry { this.monitors.add(monitor); } - public void onException(String source, Exception e) { + public void onException(DoricContext context, Exception e) { for (IDoricMonitor monitor : this.monitors) { - monitor.onException(source, e); + monitor.onException(context, e); } } diff --git a/doric-android/doric/src/main/java/pub/doric/IDoricMonitor.java b/doric-android/doric/src/main/java/pub/doric/IDoricMonitor.java index 8bc1002f..e325716f 100644 --- a/doric-android/doric/src/main/java/pub/doric/IDoricMonitor.java +++ b/doric-android/doric/src/main/java/pub/doric/IDoricMonitor.java @@ -24,11 +24,11 @@ public interface IDoricMonitor { /** * Called when native or js exception occurred in doric * - * @param source Which source file - * @param e exception which is thrown within doric sdk + * @param context Which context + * @param e exception which is thrown within doric sdk * @see com.github.pengfeizhou.jscore.JSRuntimeException */ - void onException(String source, Exception e); + void onException(DoricContext context, Exception e); /** * @param type The priority/type of this log message. diff --git a/doric-android/doric/src/main/java/pub/doric/engine/DoricJSEngine.java b/doric-android/doric/src/main/java/pub/doric/engine/DoricJSEngine.java index c6cfe3cf..e94624fe 100644 --- a/doric-android/doric/src/main/java/pub/doric/engine/DoricJSEngine.java +++ b/doric-android/doric/src/main/java/pub/doric/engine/DoricJSEngine.java @@ -25,6 +25,8 @@ import android.os.Message; import android.text.TextUtils; import android.util.Log; +import androidx.annotation.Nullable; + import com.github.pengfeizhou.jscore.JSDecoder; import com.github.pengfeizhou.jscore.JSONBuilder; import com.github.pengfeizhou.jscore.JavaFunction; @@ -132,7 +134,7 @@ public class DoricJSEngine implements Handler.Callback, DoricTimerExtension.Time break; } } catch (Exception e) { - mDoricRegistry.onException("Log", e); + mDoricRegistry.onException(null, e); } return null; } @@ -156,7 +158,7 @@ public class DoricJSEngine implements Handler.Callback, DoricTimerExtension.Time mDoricJSE.loadJS(packageModuleScript(name, content), "Module://" + name); return new JavaValue(true); } catch (Exception e) { - mDoricRegistry.onException("Require", e); + mDoricRegistry.onException(null, e); return new JavaValue(false); } } @@ -170,7 +172,7 @@ public class DoricJSEngine implements Handler.Callback, DoricTimerExtension.Time args[1].number().longValue(), args[2].bool()); } catch (Exception e) { - mDoricRegistry.onException("Timer", e); + mDoricRegistry.onException(null, e); } return null; } @@ -181,7 +183,7 @@ public class DoricJSEngine implements Handler.Callback, DoricTimerExtension.Time try { mTimerExtension.clearTimer(args[0].number().longValue()); } catch (Exception e) { - mDoricRegistry.onException("Timer", e); + mDoricRegistry.onException(null, e); } return null; } @@ -198,7 +200,7 @@ public class DoricJSEngine implements Handler.Callback, DoricTimerExtension.Time JSDecoder jsDecoder = args[4]; return mDoricBridgeExtension.callNative(contextId, module, method, callbackId, jsDecoder); } catch (Exception e) { - mDoricRegistry.onException("Bridge", e); + mDoricRegistry.onException(null, e); } return null; } @@ -212,7 +214,7 @@ public class DoricJSEngine implements Handler.Callback, DoricTimerExtension.Time String libJS = DoricUtils.readAssetFile(DoricConstant.DORIC_BUNDLE_LIB); mDoricJSE.loadJS(packageModuleScript(libName, libJS), "Module://" + libName); } catch (Exception e) { - mDoricRegistry.onException("Init Environment", e); + mDoricRegistry.onException(null, e); } } @@ -263,7 +265,7 @@ public class DoricJSEngine implements Handler.Callback, DoricTimerExtension.Time try { invokeDoricMethod(DoricConstant.DORIC_TIMER_CALLBACK, timerId); } catch (Exception e) { - mDoricRegistry.onException("Timer", e); + mDoricRegistry.onException(null, e); mDoricRegistry.onLog( Log.ERROR, String.format("Timer Callback error:%s", e.getLocalizedMessage())); @@ -275,8 +277,8 @@ public class DoricJSEngine implements Handler.Callback, DoricTimerExtension.Time } @Override - public void onException(String source, Exception e) { - Log.e(DoricJSEngine.class.getSimpleName(), "In source file: " + source); + public void onException(@Nullable DoricContext context, Exception e) { + Log.e(DoricJSEngine.class.getSimpleName(), "In source file: " + (context != null ? context.getSource() : "Unknown")); e.printStackTrace(); } diff --git a/doric-android/doric/src/main/java/pub/doric/extension/bridge/DoricBridgeExtension.java b/doric-android/doric/src/main/java/pub/doric/extension/bridge/DoricBridgeExtension.java index ba77bb2c..beebb4f8 100644 --- a/doric-android/doric/src/main/java/pub/doric/extension/bridge/DoricBridgeExtension.java +++ b/doric-android/doric/src/main/java/pub/doric/extension/bridge/DoricBridgeExtension.java @@ -98,7 +98,7 @@ public class DoricBridgeExtension { @Override public void onError(Throwable t) { context.getDriver().getRegistry().onException( - context.getSource(), + context, t instanceof Exception ? (Exception) t : new RuntimeException(t)); } @@ -120,7 +120,7 @@ public class DoricBridgeExtension { try { return DoricUtils.toJavaObject(clz, jsDecoder); } catch (Exception e) { - context.getDriver().getRegistry().onException(context.getSource(), e); + context.getDriver().getRegistry().onException(context, e); context.getDriver().getRegistry().onLog( Log.ERROR, String.format("createParam error:%s", e.getLocalizedMessage())); diff --git a/doric-android/doric/src/main/java/pub/doric/extension/bridge/DoricPromise.java b/doric-android/doric/src/main/java/pub/doric/extension/bridge/DoricPromise.java index d74fa87d..8ec27933 100644 --- a/doric-android/doric/src/main/java/pub/doric/extension/bridge/DoricPromise.java +++ b/doric-android/doric/src/main/java/pub/doric/extension/bridge/DoricPromise.java @@ -55,7 +55,7 @@ public class DoricPromise { @Override public void onError(Throwable t) { - context.getDriver().getRegistry().onException(context.getSource(), t instanceof Exception ? (Exception) t : new RuntimeException(t)); + context.getDriver().getRegistry().onException(context, t instanceof Exception ? (Exception) t : new RuntimeException(t)); } @Override @@ -82,7 +82,7 @@ public class DoricPromise { @Override public void onError(Throwable t) { - context.getDriver().getRegistry().onException(context.getSource(), t instanceof Exception ? (Exception) t : new RuntimeException(t)); + context.getDriver().getRegistry().onException(context, t instanceof Exception ? (Exception) t : new RuntimeException(t)); } @Override diff --git a/doric-android/doric/src/main/java/pub/doric/plugin/ShaderPlugin.java b/doric-android/doric/src/main/java/pub/doric/plugin/ShaderPlugin.java index 3f993a9c..99ddc6cd 100644 --- a/doric-android/doric/src/main/java/pub/doric/plugin/ShaderPlugin.java +++ b/doric-android/doric/src/main/java/pub/doric/plugin/ShaderPlugin.java @@ -79,7 +79,7 @@ public class ShaderPlugin extends DoricJavaPlugin { @Override public void onError(Throwable t) { getDoricContext().getDriver().getRegistry().onException( - getDoricContext().getSource(), + getDoricContext(), t instanceof Exception ? (Exception) t : new RuntimeException(t)); getDoricContext().getDriver().getRegistry().onLog( Log.ERROR, @@ -92,7 +92,7 @@ public class ShaderPlugin extends DoricJavaPlugin { } }); } catch (Exception e) { - getDoricContext().getDriver().getRegistry().onException(getDoricContext().getSource(), e); + getDoricContext().getDriver().getRegistry().onException(getDoricContext(), e); getDoricContext().getDriver().getRegistry().onLog( Log.ERROR, String.format("Shader.render:error%s", e.getLocalizedMessage()) @@ -173,7 +173,7 @@ public class ShaderPlugin extends DoricJavaPlugin { } } } catch (ArchiveException e) { - getDoricContext().getDriver().getRegistry().onException(getDoricContext().getSource(), e); + getDoricContext().getDriver().getRegistry().onException(getDoricContext(), e); } return new JavaValue(true); } diff --git a/doric-android/doric/src/main/java/pub/doric/shader/ImageNode.java b/doric-android/doric/src/main/java/pub/doric/shader/ImageNode.java index 6c353d51..11d70d4b 100644 --- a/doric-android/doric/src/main/java/pub/doric/shader/ImageNode.java +++ b/doric-android/doric/src/main/java/pub/doric/shader/ImageNode.java @@ -156,7 +156,7 @@ public class ImageNode extends ViewNode { if (errorDrawable != null) { requestBuilder = requestBuilder.apply(RequestOptions.errorOf(errorDrawable)); } - } catch (Exception e) { + } catch (Throwable e) { e.printStackTrace(); DoricLog.e("ImageNode blend error, please check the glide version"); } diff --git a/doric-iOS/Devkit/Classes/DoricDebugDriver.m b/doric-iOS/Devkit/Classes/DoricDebugDriver.m index f7841b82..b43c17c9 100644 --- a/doric-iOS/Devkit/Classes/DoricDebugDriver.m +++ b/doric-iOS/Devkit/Classes/DoricDebugDriver.m @@ -52,10 +52,6 @@ - (DoricRegistry *)registry { return ret; } -- (NSString *)aliasWithContextId:(NSString *)contextId { - return [[DoricContextManager instance] getContext:contextId].source; -} - - (DoricAsyncResult *)invokeDoricMethod:(NSString *)method arguments:(va_list)args { DoricAsyncResult *ret = [[DoricAsyncResult alloc] init]; NSMutableArray *array = [[NSMutableArray alloc] init]; @@ -104,7 +100,7 @@ - (DoricAsyncResult *)invokeContextEntity:(NSString *)contextId method:(NSString [ret setupResult:jsValue]; } @catch (NSException *exception) { [ret setupError:exception]; - [self.jsExecutor.registry onException:exception source:[self aliasWithContextId:contextId]]; + [self.jsExecutor.registry onException:exception inContext:[[DoricContextManager instance] getContext:contextId]]; } }); return ret; @@ -127,7 +123,7 @@ - (DoricAsyncResult *)invokeContextEntity:(NSString *)contextId method:(NSString [ret setupResult:jsValue]; } @catch (NSException *exception) { [ret setupError:exception]; - [self.jsExecutor.registry onException:exception source:[self aliasWithContextId:contextId]]; + [self.jsExecutor.registry onException:exception inContext:[[DoricContextManager instance] getContext:contextId]]; } }); return ret; @@ -144,7 +140,7 @@ - (DoricAsyncResult *)createContext:(NSString *)contextId script:(NSString *)scr [ret setupResult:@YES]; } @catch (NSException *exception) { [ret setupError:exception]; - [self.jsExecutor.registry onException:exception source:source]; + [self.jsExecutor.registry onException:exception inContext:[[DoricContextManager instance] getContext:contextId]]; } }); return ret; @@ -161,7 +157,7 @@ - (DoricAsyncResult *)destroyContext:(NSString *)contextId { [ret setupResult:@YES]; } @catch (NSException *exception) { [ret setupError:exception]; - [self.jsExecutor.registry onException:exception source:[self aliasWithContextId:contextId]]; + [self.jsExecutor.registry onException:exception inContext:[[DoricContextManager instance] getContext:contextId]]; } }); return ret; diff --git a/doric-iOS/Pod/Classes/DoricContext.m b/doric-iOS/Pod/Classes/DoricContext.m index ba6ee813..36503584 100644 --- a/doric-iOS/Pod/Classes/DoricContext.m +++ b/doric-iOS/Pod/Classes/DoricContext.m @@ -33,14 +33,14 @@ - (instancetype)initWithScript:(NSString *)script source:(NSString *)source extr if (self = [super init]) { _driver = [DoricNativeDriver instance]; _pluginInstanceMap = [NSMutableDictionary new]; - [[DoricContextManager instance] createContext:self script:script source:source]; - _headNodes = [NSMutableDictionary new]; - DoricRootNode *rootNode = [[DoricRootNode alloc] initWithContext:self]; - _rootNode = rootNode; _script = script; _source = source; _initialParams = [@{@"width": @(0), @"height": @(0)} mutableCopy]; _extra = extra; + [[DoricContextManager instance] createContext:self script:script source:source]; + _headNodes = [NSMutableDictionary new]; + DoricRootNode *rootNode = [[DoricRootNode alloc] initWithContext:self]; + _rootNode = rootNode; [self callEntity:DORIC_ENTITY_CREATE, nil]; } return self; diff --git a/doric-iOS/Pod/Classes/DoricContextManager.m b/doric-iOS/Pod/Classes/DoricContextManager.m index d567c5d2..0b4926b9 100644 --- a/doric-iOS/Pod/Classes/DoricContextManager.m +++ b/doric-iOS/Pod/Classes/DoricContextManager.m @@ -21,7 +21,6 @@ // #import "DoricContextManager.h" -#import "DoricContext.h" @interface DoricContextManager () @@ -52,11 +51,11 @@ + (instancetype)instance { - (void)createContext:(DoricContext *)context script:(NSString *)script source:(NSString *)source { context.contextId = [NSString stringWithFormat:@"%ld", (long) ++self.counter]; - [context.driver createContext:context.contextId script:script source:source]; dispatch_sync(self.mapQueue, ^() { NSValue *value = [NSValue valueWithNonretainedObject:context]; self.doricContextMap[context.contextId] = value; }); + [context.driver createContext:context.contextId script:script source:source]; } - (DoricContext *)getContext:(NSString *)contextId { diff --git a/doric-iOS/Pod/Classes/DoricDriverProtocol.h b/doric-iOS/Pod/Classes/DoricDriverProtocol.h index 1c13afb0..fc502ef5 100644 --- a/doric-iOS/Pod/Classes/DoricDriverProtocol.h +++ b/doric-iOS/Pod/Classes/DoricDriverProtocol.h @@ -42,6 +42,4 @@ - (void)ensureSyncInMainQueue:(dispatch_block_t)block; -- (NSString *)aliasWithContextId:(NSString *)contextId; - @end diff --git a/doric-iOS/Pod/Classes/DoricMonitorProtocol.h b/doric-iOS/Pod/Classes/DoricMonitorProtocol.h index 08b5d439..bb379f58 100644 --- a/doric-iOS/Pod/Classes/DoricMonitorProtocol.h +++ b/doric-iOS/Pod/Classes/DoricMonitorProtocol.h @@ -9,6 +9,7 @@ typedef NS_ENUM(NSInteger, DoricLogType) { DoricLogTypeWarning = 1, DoricLogTypeError = 2, }; +@class DoricContext; @protocol DoricMonitorProtocol /** @@ -17,7 +18,7 @@ typedef NS_ENUM(NSInteger, DoricLogType) { * @param source Which source file * @param e exception which is thrown within doric sdk */ -- (void)onException:(NSException *)exception source:(NSString *)source; +- (void)onException:(NSException *)exception inContext:(DoricContext *)context; /** * @param type The priority/type of this log message. diff --git a/doric-iOS/Pod/Classes/DoricNativeDriver.m b/doric-iOS/Pod/Classes/DoricNativeDriver.m index dfe6e472..8be6c0cb 100644 --- a/doric-iOS/Pod/Classes/DoricNativeDriver.m +++ b/doric-iOS/Pod/Classes/DoricNativeDriver.m @@ -61,10 +61,6 @@ + (instancetype)instance { return ret; } -- (NSString *)aliasWithContextId:(NSString *)contextId { - return [[DoricContextManager instance] getContext:contextId].source; -} - - (DoricAsyncResult *)invokeDoricMethod:(NSString *)method arguments:(va_list)args { DoricAsyncResult *ret = [[DoricAsyncResult alloc] init]; NSMutableArray *array = [[NSMutableArray alloc] init]; @@ -113,7 +109,7 @@ - (DoricAsyncResult *)invokeContextEntity:(NSString *)contextId method:(NSString [ret setupResult:jsValue]; } @catch (NSException *exception) { [ret setupError:exception]; - [self.jsExecutor.registry onException:exception source:[self aliasWithContextId:contextId]]; + [self.jsExecutor.registry onException:exception inContext:[[DoricContextManager instance] getContext:contextId]]; } }); return ret; @@ -136,7 +132,7 @@ - (DoricAsyncResult *)invokeContextEntity:(NSString *)contextId method:(NSString [ret setupResult:jsValue]; } @catch (NSException *exception) { [ret setupError:exception]; - [self.jsExecutor.registry onException:exception source:[self aliasWithContextId:contextId]]; + [self.jsExecutor.registry onException:exception inContext:[[DoricContextManager instance] getContext:contextId]]; } }); return ret; @@ -153,7 +149,7 @@ - (DoricAsyncResult *)createContext:(NSString *)contextId script:(NSString *)scr [ret setupResult:@YES]; } @catch (NSException *exception) { [ret setupError:exception]; - [self.jsExecutor.registry onException:exception source:source]; + [self.registry onException:exception inContext:[[DoricContextManager instance] getContext:contextId]]; } }); return ret; @@ -170,7 +166,7 @@ - (DoricAsyncResult *)destroyContext:(NSString *)contextId { [ret setupResult:@YES]; } @catch (NSException *exception) { [ret setupError:exception]; - [self.jsExecutor.registry onException:exception source:[self aliasWithContextId:contextId]]; + [self.jsExecutor.registry onException:exception inContext:[[DoricContextManager instance] getContext:contextId]]; } }); return ret; diff --git a/doric-iOS/Pod/Classes/DoricRegistry.m b/doric-iOS/Pod/Classes/DoricRegistry.m index 6caee381..df984ba2 100644 --- a/doric-iOS/Pod/Classes/DoricRegistry.m +++ b/doric-iOS/Pod/Classes/DoricRegistry.m @@ -80,8 +80,8 @@ @interface DoricDefaultMonitor : NSObject @end @implementation DoricDefaultMonitor -- (void)onException:(NSException *)exception source:(NSString *)source { - DoricLog(@"DefaultMonitor - source: %@- onException - %@", source, exception.reason); +- (void)onException:(NSException *)exception inContext:(DoricContext *)context { + DoricLog(@"DefaultMonitor - source: %@- onException - %@", context.source, exception.reason); } - (void)onLog:(DoricLogType)type message:(NSString *)message { @@ -187,9 +187,9 @@ - (void)registerMonitor:(id )monitor { [self.monitors addObject:monitor]; } -- (void)onException:(NSException *)exception source:(NSString *)source { +- (void)onException:(NSException *)exception inContext:(DoricContext *)context { for (id monitor in self.monitors) { - [monitor onException:exception source:source]; + [monitor onException:exception inContext:context]; } } diff --git a/doric-iOS/Pod/Classes/Engine/DoricJSEngine.m b/doric-iOS/Pod/Classes/Engine/DoricJSEngine.m index b519aa8e..536b20d5 100644 --- a/doric-iOS/Pod/Classes/Engine/DoricJSEngine.m +++ b/doric-iOS/Pod/Classes/Engine/DoricJSEngine.m @@ -62,7 +62,7 @@ - (instancetype)init { - (void)initJSEngine { self.jsExecutor = [DoricJSCoreExecutor new]; } - + - (void)initJSExecutor { __weak typeof(self) _self = self; NSMutableDictionary *envDic = [self.innerEnvironmentDictionary mutableCopy]; @@ -140,7 +140,7 @@ - (void)initDoricEnvironment { [self.jsExecutor loadJSScript:[self packageModuleScript:DORIC_MODULE_LIB content:jsContent] source:[@"Module://" stringByAppendingString:DORIC_MODULE_LIB]]; } @catch (NSException *exception) { - [self.registry onException:exception source:@"InitEnvironment"]; + [self.registry onException:exception inContext:nil]; } } @@ -207,7 +207,7 @@ - (void)callbackTimer:(NSTimer *)timer { @try { [self invokeDoricMethod:DORIC_TIMER_CALLBACK, timerId, nil]; } @catch (NSException *exception) { - [self.registry onException:exception source:@"Timer"]; + [self.registry onException:exception inContext:nil]; [self.registry onLog:DoricLogTypeError message:[NSString stringWithFormat:@"Timer Callback error:%@", exception.reason]]; } diff --git a/doric-iOS/Pod/Classes/Extension/DoricBridgeExtension.m b/doric-iOS/Pod/Classes/Extension/DoricBridgeExtension.m index 31063e7a..da9417ab 100644 --- a/doric-iOS/Pod/Classes/Extension/DoricBridgeExtension.m +++ b/doric-iOS/Pod/Classes/Extension/DoricBridgeExtension.m @@ -87,7 +87,7 @@ - (id)findClass:(Class)clz target:(id)target context:(DoricContext *)context met [invocation invoke]; } @catch (NSException *exception) { DoricLog(@"CallNative Error:%@", exception.reason); - [context.driver.registry onException:exception source:context.source]; + [context.driver.registry onException:exception inContext:context]; } }; diff --git a/doric-iOS/Pod/Classes/Plugin/DoricPromise.m b/doric-iOS/Pod/Classes/Plugin/DoricPromise.m index 3b042f34..ff12af7a 100644 --- a/doric-iOS/Pod/Classes/Plugin/DoricPromise.m +++ b/doric-iOS/Pod/Classes/Plugin/DoricPromise.m @@ -44,7 +44,7 @@ - (void)resolve:(id)result { setExceptionCallback:^(NSException *e) { [self.context.driver.registry onException:e - source:self.context.source]; + inContext:self.context]; }]; } @@ -53,7 +53,7 @@ - (void)reject:(id)result { setExceptionCallback:^(NSException *e) { [self.context.driver.registry onException:e - source:self.context.source]; + inContext:self.context]; }]; } @end diff --git a/doric-iOS/Pod/Classes/Plugin/DoricShaderPlugin.m b/doric-iOS/Pod/Classes/Plugin/DoricShaderPlugin.m index b0d25f1a..8e094ba6 100644 --- a/doric-iOS/Pod/Classes/Plugin/DoricShaderPlugin.m +++ b/doric-iOS/Pod/Classes/Plugin/DoricShaderPlugin.m @@ -108,7 +108,7 @@ - (id)findClass:(Class)clz target:(id)target method:(NSString *)name promise:(Do [invocation invoke]; } @catch (NSException *exception) { DoricLog(@"CallNative Error:%@", exception.reason); - [self.doricContext.driver.registry onException:exception source:self.doricContext.source]; + [self.doricContext.driver.registry onException:exception inContext:self.doricContext]; } }; dispatch_async(dispatch_get_main_queue(), ^{