feat:Android and iOS monitor use DoricContext as parameter

This commit is contained in:
pengfei.zhou 2020-03-07 10:38:42 +08:00 committed by osborn
parent 5a956950bd
commit 3b0a245129
19 changed files with 73 additions and 69 deletions

View File

@ -59,13 +59,33 @@ public class DoricNativeDriver implements IDoricDriver {
@Override @Override
public AsyncResult<JSDecoder> invokeContextEntityMethod(final String contextId, final String method, final Object... args) { public AsyncResult<JSDecoder> invokeContextEntityMethod(final String contextId, final String method, final Object... args) {
final AsyncResult<JSDecoder> asyncResult = new AsyncResult<>();
final Object[] nArgs = new Object[args.length + 2]; final Object[] nArgs = new Object[args.length + 2];
nArgs[0] = contextId; nArgs[0] = contextId;
nArgs[1] = method; nArgs[1] = method;
if (args.length > 0) { if (args.length > 0) {
System.arraycopy(args, 0, nArgs, 2, args.length); 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<JSDecoder>() {
@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 @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 @Override
public AsyncResult<Boolean> createContext(final String contextId, final String script, final String source) { public AsyncResult<Boolean> createContext(final String contextId, final String script, final String source) {
return AsyncCall.ensureRunInHandler(mJSHandler, new Callable<Boolean>() { return AsyncCall.ensureRunInHandler(mJSHandler, new Callable<Boolean>() {
@ -108,7 +120,7 @@ public class DoricNativeDriver implements IDoricDriver {
doricJSEngine.prepareContext(contextId, script, source); doricJSEngine.prepareContext(contextId, script, source);
return true; return true;
} catch (Exception e) { } 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())); doricJSEngine.getRegistry().onLog(Log.ERROR, String.format("createContext %s error is %s", source, e.getLocalizedMessage()));
return false; return false;
} }
@ -125,7 +137,7 @@ public class DoricNativeDriver implements IDoricDriver {
doricJSEngine.destroyContext(contextId); doricJSEngine.destroyContext(contextId);
return true; return true;
} catch (Exception e) { } 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())); doricJSEngine.getRegistry().onLog(Log.ERROR, String.format("destroyContext %s error is %s", contextId, e.getLocalizedMessage()));
return false; return false;
} }

View File

@ -162,9 +162,9 @@ public class DoricRegistry {
this.monitors.add(monitor); this.monitors.add(monitor);
} }
public void onException(String source, Exception e) { public void onException(DoricContext context, Exception e) {
for (IDoricMonitor monitor : this.monitors) { for (IDoricMonitor monitor : this.monitors) {
monitor.onException(source, e); monitor.onException(context, e);
} }
} }

View File

@ -24,11 +24,11 @@ public interface IDoricMonitor {
/** /**
* Called when native or js exception occurred in doric * Called when native or js exception occurred in doric
* *
* @param source Which source file * @param context Which context
* @param e exception which is thrown within doric sdk * @param e exception which is thrown within doric sdk
* @see com.github.pengfeizhou.jscore.JSRuntimeException * @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. * @param type The priority/type of this log message.

View File

@ -25,6 +25,8 @@ import android.os.Message;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import androidx.annotation.Nullable;
import com.github.pengfeizhou.jscore.JSDecoder; import com.github.pengfeizhou.jscore.JSDecoder;
import com.github.pengfeizhou.jscore.JSONBuilder; import com.github.pengfeizhou.jscore.JSONBuilder;
import com.github.pengfeizhou.jscore.JavaFunction; import com.github.pengfeizhou.jscore.JavaFunction;
@ -132,7 +134,7 @@ public class DoricJSEngine implements Handler.Callback, DoricTimerExtension.Time
break; break;
} }
} catch (Exception e) { } catch (Exception e) {
mDoricRegistry.onException("Log", e); mDoricRegistry.onException(null, e);
} }
return null; return null;
} }
@ -156,7 +158,7 @@ public class DoricJSEngine implements Handler.Callback, DoricTimerExtension.Time
mDoricJSE.loadJS(packageModuleScript(name, content), "Module://" + name); mDoricJSE.loadJS(packageModuleScript(name, content), "Module://" + name);
return new JavaValue(true); return new JavaValue(true);
} catch (Exception e) { } catch (Exception e) {
mDoricRegistry.onException("Require", e); mDoricRegistry.onException(null, e);
return new JavaValue(false); return new JavaValue(false);
} }
} }
@ -170,7 +172,7 @@ public class DoricJSEngine implements Handler.Callback, DoricTimerExtension.Time
args[1].number().longValue(), args[1].number().longValue(),
args[2].bool()); args[2].bool());
} catch (Exception e) { } catch (Exception e) {
mDoricRegistry.onException("Timer", e); mDoricRegistry.onException(null, e);
} }
return null; return null;
} }
@ -181,7 +183,7 @@ public class DoricJSEngine implements Handler.Callback, DoricTimerExtension.Time
try { try {
mTimerExtension.clearTimer(args[0].number().longValue()); mTimerExtension.clearTimer(args[0].number().longValue());
} catch (Exception e) { } catch (Exception e) {
mDoricRegistry.onException("Timer", e); mDoricRegistry.onException(null, e);
} }
return null; return null;
} }
@ -198,7 +200,7 @@ public class DoricJSEngine implements Handler.Callback, DoricTimerExtension.Time
JSDecoder jsDecoder = args[4]; JSDecoder jsDecoder = args[4];
return mDoricBridgeExtension.callNative(contextId, module, method, callbackId, jsDecoder); return mDoricBridgeExtension.callNative(contextId, module, method, callbackId, jsDecoder);
} catch (Exception e) { } catch (Exception e) {
mDoricRegistry.onException("Bridge", e); mDoricRegistry.onException(null, e);
} }
return null; return null;
} }
@ -212,7 +214,7 @@ public class DoricJSEngine implements Handler.Callback, DoricTimerExtension.Time
String libJS = DoricUtils.readAssetFile(DoricConstant.DORIC_BUNDLE_LIB); String libJS = DoricUtils.readAssetFile(DoricConstant.DORIC_BUNDLE_LIB);
mDoricJSE.loadJS(packageModuleScript(libName, libJS), "Module://" + libName); mDoricJSE.loadJS(packageModuleScript(libName, libJS), "Module://" + libName);
} catch (Exception e) { } 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 { try {
invokeDoricMethod(DoricConstant.DORIC_TIMER_CALLBACK, timerId); invokeDoricMethod(DoricConstant.DORIC_TIMER_CALLBACK, timerId);
} catch (Exception e) { } catch (Exception e) {
mDoricRegistry.onException("Timer", e); mDoricRegistry.onException(null, e);
mDoricRegistry.onLog( mDoricRegistry.onLog(
Log.ERROR, Log.ERROR,
String.format("Timer Callback error:%s", e.getLocalizedMessage())); String.format("Timer Callback error:%s", e.getLocalizedMessage()));
@ -275,8 +277,8 @@ public class DoricJSEngine implements Handler.Callback, DoricTimerExtension.Time
} }
@Override @Override
public void onException(String source, Exception e) { public void onException(@Nullable DoricContext context, Exception e) {
Log.e(DoricJSEngine.class.getSimpleName(), "In source file: " + source); Log.e(DoricJSEngine.class.getSimpleName(), "In source file: " + (context != null ? context.getSource() : "Unknown"));
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -98,7 +98,7 @@ public class DoricBridgeExtension {
@Override @Override
public void onError(Throwable t) { public void onError(Throwable t) {
context.getDriver().getRegistry().onException( context.getDriver().getRegistry().onException(
context.getSource(), context,
t instanceof Exception ? (Exception) t : new RuntimeException(t)); t instanceof Exception ? (Exception) t : new RuntimeException(t));
} }
@ -120,7 +120,7 @@ public class DoricBridgeExtension {
try { try {
return DoricUtils.toJavaObject(clz, jsDecoder); return DoricUtils.toJavaObject(clz, jsDecoder);
} catch (Exception e) { } catch (Exception e) {
context.getDriver().getRegistry().onException(context.getSource(), e); context.getDriver().getRegistry().onException(context, e);
context.getDriver().getRegistry().onLog( context.getDriver().getRegistry().onLog(
Log.ERROR, Log.ERROR,
String.format("createParam error:%s", e.getLocalizedMessage())); String.format("createParam error:%s", e.getLocalizedMessage()));

View File

@ -55,7 +55,7 @@ public class DoricPromise {
@Override @Override
public void onError(Throwable t) { 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 @Override
@ -82,7 +82,7 @@ public class DoricPromise {
@Override @Override
public void onError(Throwable t) { 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 @Override

View File

@ -79,7 +79,7 @@ public class ShaderPlugin extends DoricJavaPlugin {
@Override @Override
public void onError(Throwable t) { public void onError(Throwable t) {
getDoricContext().getDriver().getRegistry().onException( getDoricContext().getDriver().getRegistry().onException(
getDoricContext().getSource(), getDoricContext(),
t instanceof Exception ? (Exception) t : new RuntimeException(t)); t instanceof Exception ? (Exception) t : new RuntimeException(t));
getDoricContext().getDriver().getRegistry().onLog( getDoricContext().getDriver().getRegistry().onLog(
Log.ERROR, Log.ERROR,
@ -92,7 +92,7 @@ public class ShaderPlugin extends DoricJavaPlugin {
} }
}); });
} catch (Exception e) { } catch (Exception e) {
getDoricContext().getDriver().getRegistry().onException(getDoricContext().getSource(), e); getDoricContext().getDriver().getRegistry().onException(getDoricContext(), e);
getDoricContext().getDriver().getRegistry().onLog( getDoricContext().getDriver().getRegistry().onLog(
Log.ERROR, Log.ERROR,
String.format("Shader.render:error%s", e.getLocalizedMessage()) String.format("Shader.render:error%s", e.getLocalizedMessage())
@ -173,7 +173,7 @@ public class ShaderPlugin extends DoricJavaPlugin {
} }
} }
} catch (ArchiveException e) { } catch (ArchiveException e) {
getDoricContext().getDriver().getRegistry().onException(getDoricContext().getSource(), e); getDoricContext().getDriver().getRegistry().onException(getDoricContext(), e);
} }
return new JavaValue(true); return new JavaValue(true);
} }

View File

@ -156,7 +156,7 @@ public class ImageNode extends ViewNode<ImageView> {
if (errorDrawable != null) { if (errorDrawable != null) {
requestBuilder = requestBuilder.apply(RequestOptions.errorOf(errorDrawable)); requestBuilder = requestBuilder.apply(RequestOptions.errorOf(errorDrawable));
} }
} catch (Exception e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
DoricLog.e("ImageNode blend error, please check the glide version"); DoricLog.e("ImageNode blend error, please check the glide version");
} }

View File

@ -52,10 +52,6 @@ - (DoricRegistry *)registry {
return ret; return ret;
} }
- (NSString *)aliasWithContextId:(NSString *)contextId {
return [[DoricContextManager instance] getContext:contextId].source;
}
- (DoricAsyncResult<JSValue *> *)invokeDoricMethod:(NSString *)method arguments:(va_list)args { - (DoricAsyncResult<JSValue *> *)invokeDoricMethod:(NSString *)method arguments:(va_list)args {
DoricAsyncResult *ret = [[DoricAsyncResult alloc] init]; DoricAsyncResult *ret = [[DoricAsyncResult alloc] init];
NSMutableArray *array = [[NSMutableArray alloc] init]; NSMutableArray *array = [[NSMutableArray alloc] init];
@ -104,7 +100,7 @@ - (DoricAsyncResult *)invokeContextEntity:(NSString *)contextId method:(NSString
[ret setupResult:jsValue]; [ret setupResult:jsValue];
} @catch (NSException *exception) { } @catch (NSException *exception) {
[ret setupError: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; return ret;
@ -127,7 +123,7 @@ - (DoricAsyncResult *)invokeContextEntity:(NSString *)contextId method:(NSString
[ret setupResult:jsValue]; [ret setupResult:jsValue];
} @catch (NSException *exception) { } @catch (NSException *exception) {
[ret setupError: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; return ret;
@ -144,7 +140,7 @@ - (DoricAsyncResult *)createContext:(NSString *)contextId script:(NSString *)scr
[ret setupResult:@YES]; [ret setupResult:@YES];
} @catch (NSException *exception) { } @catch (NSException *exception) {
[ret setupError:exception]; [ret setupError:exception];
[self.jsExecutor.registry onException:exception source:source]; [self.jsExecutor.registry onException:exception inContext:[[DoricContextManager instance] getContext:contextId]];
} }
}); });
return ret; return ret;
@ -161,7 +157,7 @@ - (DoricAsyncResult *)destroyContext:(NSString *)contextId {
[ret setupResult:@YES]; [ret setupResult:@YES];
} @catch (NSException *exception) { } @catch (NSException *exception) {
[ret setupError: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; return ret;

View File

@ -33,14 +33,14 @@ - (instancetype)initWithScript:(NSString *)script source:(NSString *)source extr
if (self = [super init]) { if (self = [super init]) {
_driver = [DoricNativeDriver instance]; _driver = [DoricNativeDriver instance];
_pluginInstanceMap = [NSMutableDictionary new]; _pluginInstanceMap = [NSMutableDictionary new];
[[DoricContextManager instance] createContext:self script:script source:source];
_headNodes = [NSMutableDictionary new];
DoricRootNode *rootNode = [[DoricRootNode alloc] initWithContext:self];
_rootNode = rootNode;
_script = script; _script = script;
_source = source; _source = source;
_initialParams = [@{@"width": @(0), @"height": @(0)} mutableCopy]; _initialParams = [@{@"width": @(0), @"height": @(0)} mutableCopy];
_extra = extra; _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]; [self callEntity:DORIC_ENTITY_CREATE, nil];
} }
return self; return self;

View File

@ -21,7 +21,6 @@
// //
#import "DoricContextManager.h" #import "DoricContextManager.h"
#import "DoricContext.h"
@interface DoricContextManager () @interface DoricContextManager ()
@ -52,11 +51,11 @@ + (instancetype)instance {
- (void)createContext:(DoricContext *)context script:(NSString *)script source:(NSString *)source { - (void)createContext:(DoricContext *)context script:(NSString *)script source:(NSString *)source {
context.contextId = [NSString stringWithFormat:@"%ld", (long) ++self.counter]; context.contextId = [NSString stringWithFormat:@"%ld", (long) ++self.counter];
[context.driver createContext:context.contextId script:script source:source];
dispatch_sync(self.mapQueue, ^() { dispatch_sync(self.mapQueue, ^() {
NSValue *value = [NSValue valueWithNonretainedObject:context]; NSValue *value = [NSValue valueWithNonretainedObject:context];
self.doricContextMap[context.contextId] = value; self.doricContextMap[context.contextId] = value;
}); });
[context.driver createContext:context.contextId script:script source:source];
} }
- (DoricContext *)getContext:(NSString *)contextId { - (DoricContext *)getContext:(NSString *)contextId {

View File

@ -42,6 +42,4 @@
- (void)ensureSyncInMainQueue:(dispatch_block_t)block; - (void)ensureSyncInMainQueue:(dispatch_block_t)block;
- (NSString *)aliasWithContextId:(NSString *)contextId;
@end @end

View File

@ -9,6 +9,7 @@ typedef NS_ENUM(NSInteger, DoricLogType) {
DoricLogTypeWarning = 1, DoricLogTypeWarning = 1,
DoricLogTypeError = 2, DoricLogTypeError = 2,
}; };
@class DoricContext;
@protocol DoricMonitorProtocol <NSObject> @protocol DoricMonitorProtocol <NSObject>
/** /**
@ -17,7 +18,7 @@ typedef NS_ENUM(NSInteger, DoricLogType) {
* @param source Which source file * @param source Which source file
* @param e exception which is thrown within doric sdk * @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. * @param type The priority/type of this log message.

View File

@ -61,10 +61,6 @@ + (instancetype)instance {
return ret; return ret;
} }
- (NSString *)aliasWithContextId:(NSString *)contextId {
return [[DoricContextManager instance] getContext:contextId].source;
}
- (DoricAsyncResult<JSValue *> *)invokeDoricMethod:(NSString *)method arguments:(va_list)args { - (DoricAsyncResult<JSValue *> *)invokeDoricMethod:(NSString *)method arguments:(va_list)args {
DoricAsyncResult *ret = [[DoricAsyncResult alloc] init]; DoricAsyncResult *ret = [[DoricAsyncResult alloc] init];
NSMutableArray *array = [[NSMutableArray alloc] init]; NSMutableArray *array = [[NSMutableArray alloc] init];
@ -113,7 +109,7 @@ - (DoricAsyncResult *)invokeContextEntity:(NSString *)contextId method:(NSString
[ret setupResult:jsValue]; [ret setupResult:jsValue];
} @catch (NSException *exception) { } @catch (NSException *exception) {
[ret setupError: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; return ret;
@ -136,7 +132,7 @@ - (DoricAsyncResult *)invokeContextEntity:(NSString *)contextId method:(NSString
[ret setupResult:jsValue]; [ret setupResult:jsValue];
} @catch (NSException *exception) { } @catch (NSException *exception) {
[ret setupError: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; return ret;
@ -153,7 +149,7 @@ - (DoricAsyncResult *)createContext:(NSString *)contextId script:(NSString *)scr
[ret setupResult:@YES]; [ret setupResult:@YES];
} @catch (NSException *exception) { } @catch (NSException *exception) {
[ret setupError:exception]; [ret setupError:exception];
[self.jsExecutor.registry onException:exception source:source]; [self.registry onException:exception inContext:[[DoricContextManager instance] getContext:contextId]];
} }
}); });
return ret; return ret;
@ -170,7 +166,7 @@ - (DoricAsyncResult *)destroyContext:(NSString *)contextId {
[ret setupResult:@YES]; [ret setupResult:@YES];
} @catch (NSException *exception) { } @catch (NSException *exception) {
[ret setupError: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; return ret;

View File

@ -80,8 +80,8 @@ @interface DoricDefaultMonitor : NSObject <DoricMonitorProtocol>
@end @end
@implementation DoricDefaultMonitor @implementation DoricDefaultMonitor
- (void)onException:(NSException *)exception source:(NSString *)source { - (void)onException:(NSException *)exception inContext:(DoricContext *)context {
DoricLog(@"DefaultMonitor - source: %@- onException - %@", source, exception.reason); DoricLog(@"DefaultMonitor - source: %@- onException - %@", context.source, exception.reason);
} }
- (void)onLog:(DoricLogType)type message:(NSString *)message { - (void)onLog:(DoricLogType)type message:(NSString *)message {
@ -187,9 +187,9 @@ - (void)registerMonitor:(id <DoricMonitorProtocol>)monitor {
[self.monitors addObject:monitor]; [self.monitors addObject:monitor];
} }
- (void)onException:(NSException *)exception source:(NSString *)source { - (void)onException:(NSException *)exception inContext:(DoricContext *)context {
for (id <DoricMonitorProtocol> monitor in self.monitors) { for (id <DoricMonitorProtocol> monitor in self.monitors) {
[monitor onException:exception source:source]; [monitor onException:exception inContext:context];
} }
} }

View File

@ -62,7 +62,7 @@ - (instancetype)init {
- (void)initJSEngine { - (void)initJSEngine {
self.jsExecutor = [DoricJSCoreExecutor new]; self.jsExecutor = [DoricJSCoreExecutor new];
} }
- (void)initJSExecutor { - (void)initJSExecutor {
__weak typeof(self) _self = self; __weak typeof(self) _self = self;
NSMutableDictionary *envDic = [self.innerEnvironmentDictionary mutableCopy]; NSMutableDictionary *envDic = [self.innerEnvironmentDictionary mutableCopy];
@ -140,7 +140,7 @@ - (void)initDoricEnvironment {
[self.jsExecutor loadJSScript:[self packageModuleScript:DORIC_MODULE_LIB content:jsContent] [self.jsExecutor loadJSScript:[self packageModuleScript:DORIC_MODULE_LIB content:jsContent]
source:[@"Module://" stringByAppendingString:DORIC_MODULE_LIB]]; source:[@"Module://" stringByAppendingString:DORIC_MODULE_LIB]];
} @catch (NSException *exception) { } @catch (NSException *exception) {
[self.registry onException:exception source:@"InitEnvironment"]; [self.registry onException:exception inContext:nil];
} }
} }
@ -207,7 +207,7 @@ - (void)callbackTimer:(NSTimer *)timer {
@try { @try {
[self invokeDoricMethod:DORIC_TIMER_CALLBACK, timerId, nil]; [self invokeDoricMethod:DORIC_TIMER_CALLBACK, timerId, nil];
} @catch (NSException *exception) { } @catch (NSException *exception) {
[self.registry onException:exception source:@"Timer"]; [self.registry onException:exception inContext:nil];
[self.registry onLog:DoricLogTypeError [self.registry onLog:DoricLogTypeError
message:[NSString stringWithFormat:@"Timer Callback error:%@", exception.reason]]; message:[NSString stringWithFormat:@"Timer Callback error:%@", exception.reason]];
} }

View File

@ -87,7 +87,7 @@ - (id)findClass:(Class)clz target:(id)target context:(DoricContext *)context met
[invocation invoke]; [invocation invoke];
} @catch (NSException *exception) { } @catch (NSException *exception) {
DoricLog(@"CallNative Error:%@", exception.reason); DoricLog(@"CallNative Error:%@", exception.reason);
[context.driver.registry onException:exception source:context.source]; [context.driver.registry onException:exception inContext:context];
} }
}; };

View File

@ -44,7 +44,7 @@ - (void)resolve:(id)result {
setExceptionCallback:^(NSException *e) { setExceptionCallback:^(NSException *e) {
[self.context.driver.registry [self.context.driver.registry
onException:e onException:e
source:self.context.source]; inContext:self.context];
}]; }];
} }
@ -53,7 +53,7 @@ - (void)reject:(id)result {
setExceptionCallback:^(NSException *e) { setExceptionCallback:^(NSException *e) {
[self.context.driver.registry [self.context.driver.registry
onException:e onException:e
source:self.context.source]; inContext:self.context];
}]; }];
} }
@end @end

View File

@ -108,7 +108,7 @@ - (id)findClass:(Class)clz target:(id)target method:(NSString *)name promise:(Do
[invocation invoke]; [invocation invoke];
} @catch (NSException *exception) { } @catch (NSException *exception) {
DoricLog(@"CallNative Error:%@", exception.reason); 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(), ^{ dispatch_async(dispatch_get_main_queue(), ^{