You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by so...@apache.org on 2017/02/28 02:29:44 UTC

[04/50] incubator-weex git commit: * [ios] call js exception handler

* [ios] call js exception handler


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/acb93b07
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/acb93b07
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/acb93b07

Branch: refs/heads/0.11-dev
Commit: acb93b0729bd7c646aae31e41b1028b90d8034a4
Parents: 0a7ba30
Author: acton393 <zh...@gmail.com>
Authored: Tue Feb 21 18:14:03 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Tue Feb 21 18:14:03 2017 +0800

----------------------------------------------------------------------
 ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.m | 8 ++++++++
 1 file changed, 8 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/acb93b07/ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.m b/ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.m
index 1ebfa6b..9d63b1e 100644
--- a/ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.m
+++ b/ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.m
@@ -21,6 +21,7 @@
 #import <JavaScriptCore/JavaScriptCore.h>
 #import "WXPolyfillSet.h"
 #import "JSValue+Weex.h"
+#import "WXJSExceptionProtocol.h"
 
 #import <dlfcn.h>
 
@@ -97,6 +98,13 @@
             context.exception = exception;
             NSString *message = [NSString stringWithFormat:@"[%@:%@:%@] %@\n%@", exception[@"sourceURL"], exception[@"line"], exception[@"column"], exception, [exception[@"stack"] toObject]];
             
+            
+            id<WXJSExceptionProtocol> handler = [WXSDKEngine handlerForProtocol:@protocol(WXJSExceptionProtocol)];
+            if ([handler respondsToSelector:@selector(onJSException:)]) {
+                WXSDKInstance *instance = [WXSDKEngine topInstance];
+                WXJSExceptionInfo * jsException = [[WXJSExceptionInfo alloc] initWithInstanceId:instance.instanceId bundleUrl:[instance.scriptURL absoluteString] errorCode:@"" functionName:@"" exception:[NSString stringWithFormat:@"%@\n%@",[exception toString], exception[@"stack"]] userInfo:nil];
+                [handler onJSException:jsException];
+            }
             WX_MONITOR_FAIL(WXMTJSBridge, WX_ERR_JS_EXECUTE, message);
         };