[ 
https://issues.apache.org/jira/browse/WEEX-569?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16582183#comment-16582183
 ] 

ASF GitHub Bot commented on WEEX-569:
-------------------------------------

cxfeng1 closed pull request #1440: [WEEX-569][iOS] fix degrade_error not report
URL: https://github.com/apache/incubator-weex/pull/1440
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/ios/sdk/WeexSDK/Sources/Engine/WXSDKError.h 
b/ios/sdk/WeexSDK/Sources/Engine/WXSDKError.h
index 7b82798c4f..ba446b2521 100644
--- a/ios/sdk/WeexSDK/Sources/Engine/WXSDKError.h
+++ b/ios/sdk/WeexSDK/Sources/Engine/WXSDKError.h
@@ -20,6 +20,16 @@
 #import <Foundation/Foundation.h>
 #import "WXSDKInstance.h"
 
+#define WX_ERROR_GROUP_NATIVE   @"NATIVE"
+#define WX_ERROR_GROUP_JS       @"JS"
+#define WX_ERROR_GROUP_NET      @"NET"
+
+#define WX_ERROR_TYPE_NATIVE    @"NATIVE_ERROR"
+#define WX_ERROR_TYPE_JS        @"JS_ERROR"
+#define WX_ERROR_TYPE_DEGRADE    @"DEGRADE_ERROR"
+#define WX_ERROR_TYPE_RENDER    @"RENDER_ERROR"
+
+
 typedef NS_ENUM(int, WXSDKErrCode)
 {
     WX_ERR_JSFRAMEWORK_START = -1001,
@@ -62,6 +72,7 @@ typedef NS_ENUM(int, WXSDKErrCode)
     WX_KEY_EXCEPTION_DEGRADE_CHECK_CONTENT_LENGTH_FAILED = -9501,
     WX_KEY_EXCEPTION_DEGRADE_BUNDLE_CONTENTTYPE_ERROR = -9502,
     WX_KEY_EXCEPTION_DEGRADE_OTHER_CAUSE = -9503,
+    WX_KEY_EXCEPTION_DEGRADE_NET_CODE_CAUSE = -9504,
     
     WX_KEY_EXCEPTION_ABILITY_DOWN = -9600,
     WX_KEY_EXCEPTION_ABILITY_DOWN_IMAGE = -9601,
@@ -71,23 +82,26 @@ typedef NS_ENUM(int, WXSDKErrCode)
     WX_KEY_EXCEPTION_EMPTY_SCREEN_JS = -9700
 };
 
-typedef NS_ENUM (int,WXSDKErrorType)
+typedef NS_ENUM (NSInteger,WXSDKErrorType)
 {
-    JS_ERROR,
-    NATIVE_ERROR,
-    RENDER_ERROR,
-    DEGRAD_ERROR
+    WX_JS_ERROR,
+    WX_NATIVE_ERROR,
+    WX_RENDER_ERROR,
+    WX_DEGRADE_ERROR
 };
 
-typedef NS_ENUM (int,WXSDKErrorGroup){
-    JS,
-    NATIVE
+typedef NS_ENUM (NSInteger,WXSDKErrorGroup){
+    WX_JS,
+    WX_NATIVE,
+    WX_NET
 };
 
 @interface WXSDKErrCodeUtil :NSObject
 
 + (WXSDKErrorType) getErrorTypeByCode:(WXSDKErrCode) code;
 + (WXSDKErrorGroup) getErrorGroupByCode:(WXSDKErrCode) code;
++ (NSString *) convertGroupToStringName:(WXSDKErrorGroup) group;
++ (NSString *) convertTypeToStringName:(WXSDKErrorType)type;
 
 @end
 
diff --git a/ios/sdk/WeexSDK/Sources/Engine/WXSDKError.m 
b/ios/sdk/WeexSDK/Sources/Engine/WXSDKError.m
index 90ea06fc56..c3b9a7791a 100644
--- a/ios/sdk/WeexSDK/Sources/Engine/WXSDKError.m
+++ b/ios/sdk/WeexSDK/Sources/Engine/WXSDKError.m
@@ -29,7 +29,7 @@ +(WXSDKErrorType)getErrorTypeByCode:(WXSDKErrCode)code
 {
     NSDictionary* codeMap = [[self getMap] objectForKey:@(code)];
     if (!codeMap) {
-        return NATIVE_ERROR;
+        return WX_NATIVE_ERROR;
     }
     return [[codeMap objectForKey:ERROR_TYPE] intValue];
 }
@@ -39,7 +39,7 @@ +(WXSDKErrorGroup) getErrorGroupByCode:(WXSDKErrCode)code
 {
     NSDictionary* codeMap = [[self getMap] objectForKey:@(code)];
     if (!codeMap) {
-        return NATIVE;
+        return WX_NATIVE;
     }
     return [[codeMap objectForKey:ERROR_GROUP] intValue];
 }
@@ -52,56 +52,85 @@ +(NSDictionary *) getMap
     dispatch_once(&onceToken, ^{
         
         codeMap=@{
-                
@(WX_ERR_JSFRAMEWORK_START):@{ERROR_TYPE:@(NATIVE_ERROR),ERROR_GROUP:@(NATIVE)},
-                
@(WX_ERR_JSFRAMEWORK_LOAD):@{ERROR_TYPE:@(NATIVE_ERROR),ERROR_GROUP:@(NATIVE)},
-                
@(WX_ERR_JSFRAMEWORK_EXECUTE):@{ERROR_TYPE:@(NATIVE_ERROR),ERROR_GROUP:@(NATIVE)},
-                
@(WX_ERR_JSFRAMEWORK_END):@{ERROR_TYPE:@(NATIVE_ERROR),ERROR_GROUP:@(NATIVE)},
+                
@(WX_ERR_JSFRAMEWORK_START):@{ERROR_TYPE:@(WX_NATIVE_ERROR),ERROR_GROUP:@(WX_NATIVE)},
+                
@(WX_ERR_JSFRAMEWORK_LOAD):@{ERROR_TYPE:@(WX_NATIVE_ERROR),ERROR_GROUP:@(WX_NATIVE)},
+                
@(WX_ERR_JSFRAMEWORK_EXECUTE):@{ERROR_TYPE:@(WX_NATIVE_ERROR),ERROR_GROUP:@(WX_NATIVE)},
+                
@(WX_ERR_JSFRAMEWORK_END):@{ERROR_TYPE:@(WX_NATIVE_ERROR),ERROR_GROUP:@(WX_NATIVE)},
                 
-                
@(WX_ERR_JSBRIDGE_START):@{ERROR_TYPE:@(NATIVE_ERROR),ERROR_GROUP:@(NATIVE)},
-                
@(WX_ERR_RENDER_CREATEBODY):@{ERROR_TYPE:@(NATIVE_ERROR),ERROR_GROUP:@(NATIVE)},
-                
@(WX_ERR_INVOKE_NATIVE):@{ERROR_TYPE:@(NATIVE_ERROR),ERROR_GROUP:@(NATIVE)},
-                
@(WX_ERR_JS_EXECUTE):@{ERROR_TYPE:@(JS_ERROR),ERROR_GROUP:@(JS)},
-                
@(WX_ERR_JSBRIDGE_END):@{ERROR_TYPE:@(JS_ERROR),ERROR_GROUP:@(JS)},
+                
@(WX_ERR_JSBRIDGE_START):@{ERROR_TYPE:@(WX_NATIVE_ERROR),ERROR_GROUP:@(WX_NATIVE)},
+                
@(WX_ERR_RENDER_CREATEBODY):@{ERROR_TYPE:@(WX_NATIVE_ERROR),ERROR_GROUP:@(WX_NATIVE)},
+                
@(WX_ERR_INVOKE_NATIVE):@{ERROR_TYPE:@(WX_NATIVE_ERROR),ERROR_GROUP:@(WX_NATIVE)},
+                
@(WX_ERR_JS_EXECUTE):@{ERROR_TYPE:@(WX_JS_ERROR),ERROR_GROUP:@(WX_JS)},
+                
@(WX_ERR_JSBRIDGE_END):@{ERROR_TYPE:@(WX_JS_ERROR),ERROR_GROUP:@(WX_JS)},
                 
-                
@(WX_ERR_RENDER_START):@{ERROR_TYPE:@(NATIVE_ERROR),ERROR_GROUP:@(NATIVE)},
-                
@(WX_ERR_JSFRAMEWORK_START):@{ERROR_TYPE:@(NATIVE_ERROR),ERROR_GROUP:@(NATIVE)},
-                
@(WX_ERR_RENDER_UPDATTR):@{ERROR_TYPE:@(NATIVE_ERROR),ERROR_GROUP:@(NATIVE)},
-                
@(WX_ERR_RENDER_UPDSTYLE):@{ERROR_TYPE:@(NATIVE_ERROR),ERROR_GROUP:@(NATIVE)},
-                
@(WX_ERR_RENDER_ADDELEMENT):@{ERROR_TYPE:@(NATIVE_ERROR),ERROR_GROUP:@(NATIVE)},
-                
@(WX_ERR_RENDER_REMOVEELEMENT):@{ERROR_TYPE:@(NATIVE_ERROR),ERROR_GROUP:@(NATIVE)},
-                
@(WX_ERR_RENDER_MOVEELEMENT):@{ERROR_TYPE:@(NATIVE_ERROR),ERROR_GROUP:@(NATIVE)},
-                
@(WX_ERR_RENDER_ADDEVENT):@{ERROR_TYPE:@(NATIVE_ERROR),ERROR_GROUP:@(NATIVE)},
-                
@(WX_ERR_RENDER_REMOVEEVENT):@{ERROR_TYPE:@(NATIVE_ERROR),ERROR_GROUP:@(NATIVE)},
-                
@(WX_ERR_RENDER_SCROLLTOELEMENT):@{ERROR_TYPE:@(NATIVE_ERROR),ERROR_GROUP:@(NATIVE)},
-                
@(WX_ERR_RENDER_END):@{ERROR_TYPE:@(NATIVE_ERROR),ERROR_GROUP:@(NATIVE)},
+                
@(WX_ERR_RENDER_START):@{ERROR_TYPE:@(WX_NATIVE_ERROR),ERROR_GROUP:@(WX_NATIVE)},
+                
@(WX_ERR_JSFRAMEWORK_START):@{ERROR_TYPE:@(WX_NATIVE_ERROR),ERROR_GROUP:@(WX_NATIVE)},
+                
@(WX_ERR_RENDER_UPDATTR):@{ERROR_TYPE:@(WX_NATIVE_ERROR),ERROR_GROUP:@(WX_NATIVE)},
+                
@(WX_ERR_RENDER_UPDSTYLE):@{ERROR_TYPE:@(WX_NATIVE_ERROR),ERROR_GROUP:@(WX_NATIVE)},
+                
@(WX_ERR_RENDER_ADDELEMENT):@{ERROR_TYPE:@(WX_NATIVE_ERROR),ERROR_GROUP:@(WX_NATIVE)},
+                
@(WX_ERR_RENDER_REMOVEELEMENT):@{ERROR_TYPE:@(WX_NATIVE_ERROR),ERROR_GROUP:@(WX_NATIVE)},
+                
@(WX_ERR_RENDER_MOVEELEMENT):@{ERROR_TYPE:@(WX_NATIVE_ERROR),ERROR_GROUP:@(WX_NATIVE)},
+                
@(WX_ERR_RENDER_ADDEVENT):@{ERROR_TYPE:@(WX_NATIVE_ERROR),ERROR_GROUP:@(WX_NATIVE)},
+                
@(WX_ERR_RENDER_REMOVEEVENT):@{ERROR_TYPE:@(WX_NATIVE_ERROR),ERROR_GROUP:@(WX_NATIVE)},
+                
@(WX_ERR_RENDER_SCROLLTOELEMENT):@{ERROR_TYPE:@(WX_NATIVE_ERROR),ERROR_GROUP:@(WX_NATIVE)},
+                
@(WX_ERR_RENDER_END):@{ERROR_TYPE:@(WX_NATIVE_ERROR),ERROR_GROUP:@(WX_NATIVE)},
                 
-                
@(WX_ERR_DOWNLOAD_START):@{ERROR_TYPE:@(NATIVE_ERROR),ERROR_GROUP:@(NATIVE)},
-                
@(WX_ERR_JSBUNDLE_DOWNLOAD):@{ERROR_TYPE:@(NATIVE_ERROR),ERROR_GROUP:@(NATIVE)},
-                
@(WX_ERR_JSBUNDLE_STRING_CONVERT):@{ERROR_TYPE:@(NATIVE_ERROR),ERROR_GROUP:@(NATIVE)},
-                
@(WX_ERR_NOT_CONNECTED_TO_INTERNET):@{ERROR_TYPE:@(NATIVE_ERROR),ERROR_GROUP:@(NATIVE)},
-                
@(WX_ERR_CANCEL):@{ERROR_TYPE:@(NATIVE_ERROR),ERROR_GROUP:@(NATIVE)},
-                
@(WX_ERR_DOWNLOAD_END):@{ERROR_TYPE:@(NATIVE_ERROR),ERROR_GROUP:@(NATIVE)},
+                
@(WX_ERR_DOWNLOAD_START):@{ERROR_TYPE:@(WX_NATIVE_ERROR),ERROR_GROUP:@(WX_NATIVE)},
+                
@(WX_ERR_JSBUNDLE_DOWNLOAD):@{ERROR_TYPE:@(WX_NATIVE_ERROR),ERROR_GROUP:@(WX_NATIVE)},
+                
@(WX_ERR_JSBUNDLE_STRING_CONVERT):@{ERROR_TYPE:@(WX_NATIVE_ERROR),ERROR_GROUP:@(WX_NATIVE)},
+                
@(WX_ERR_NOT_CONNECTED_TO_INTERNET):@{ERROR_TYPE:@(WX_NATIVE_ERROR),ERROR_GROUP:@(WX_NATIVE)},
+                
@(WX_ERR_CANCEL):@{ERROR_TYPE:@(WX_NATIVE_ERROR),ERROR_GROUP:@(WX_NATIVE)},
+                
@(WX_ERR_DOWNLOAD_END):@{ERROR_TYPE:@(WX_NATIVE_ERROR),ERROR_GROUP:@(WX_NATIVE)},
                 
-                
@(WX_KEY_EXCEPTION_SDK_INIT):@{ERROR_TYPE:@(NATIVE_ERROR),ERROR_GROUP:@(NATIVE)},
-                
@(WX_KEY_EXCEPTION_INVOKE):@{ERROR_TYPE:@(NATIVE_ERROR),ERROR_GROUP:@(NATIVE)},
-                
@(WX_KEY_EXCEPTION_JS_DOWNLOAD):@{ERROR_TYPE:@(NATIVE_ERROR),ERROR_GROUP:@(NATIVE)},
-                
@(WX_KEY_EXCEPTION_DOM):@{ERROR_TYPE:@(NATIVE_ERROR),ERROR_GROUP:@(NATIVE)},
-                
@(WX_KEY_EXCEPTION_WXBRIDGE):@{ERROR_TYPE:@(JS_ERROR),ERROR_GROUP:@(JS)},
+                
@(WX_KEY_EXCEPTION_SDK_INIT):@{ERROR_TYPE:@(WX_NATIVE_ERROR),ERROR_GROUP:@(WX_NATIVE)},
+                
@(WX_KEY_EXCEPTION_INVOKE):@{ERROR_TYPE:@(WX_NATIVE_ERROR),ERROR_GROUP:@(WX_NATIVE)},
+                
@(WX_KEY_EXCEPTION_JS_DOWNLOAD):@{ERROR_TYPE:@(WX_NATIVE_ERROR),ERROR_GROUP:@(WX_NATIVE)},
+                
@(WX_KEY_EXCEPTION_DOM):@{ERROR_TYPE:@(WX_NATIVE_ERROR),ERROR_GROUP:@(WX_NATIVE)},
+                
@(WX_KEY_EXCEPTION_WXBRIDGE):@{ERROR_TYPE:@(WX_JS_ERROR),ERROR_GROUP:@(WX_JS)},
                 
-                
@(WX_KEY_EXCEPTION_DEGRADE):@{ERROR_TYPE:@(DEGRAD_ERROR),ERROR_GROUP:@(NATIVE)},
-                
@(WX_KEY_EXCEPTION_DEGRADE_CHECK_CONTENT_LENGTH_FAILED):@{ERROR_TYPE:@(DEGRAD_ERROR),ERROR_GROUP:@(NATIVE)},
-                
@(WX_KEY_EXCEPTION_DEGRADE_BUNDLE_CONTENTTYPE_ERROR):@{ERROR_TYPE:@(DEGRAD_ERROR),ERROR_GROUP:@(NATIVE)},
-                
@(WX_KEY_EXCEPTION_DEGRADE_OTHER_CAUSE):@{ERROR_TYPE:@(DEGRAD_ERROR),ERROR_GROUP:@(NATIVE)},
+                
@(WX_KEY_EXCEPTION_DEGRADE):@{ERROR_TYPE:@(WX_DEGRADE_ERROR),ERROR_GROUP:@(WX_NATIVE)},
+                
@(WX_KEY_EXCEPTION_DEGRADE_CHECK_CONTENT_LENGTH_FAILED):@{ERROR_TYPE:@(WX_DEGRADE_ERROR),ERROR_GROUP:@(WX_NET)},
+                
@(WX_KEY_EXCEPTION_DEGRADE_BUNDLE_CONTENTTYPE_ERROR):@{ERROR_TYPE:@(WX_DEGRADE_ERROR),ERROR_GROUP:@(WX_NET)},
+                
@(WX_KEY_EXCEPTION_DEGRADE_OTHER_CAUSE):@{ERROR_TYPE:@(WX_DEGRADE_ERROR),ERROR_GROUP:@(WX_NATIVE)},
+                
@(WX_KEY_EXCEPTION_DEGRADE_NET_CODE_CAUSE):@{ERROR_TYPE:@(WX_DEGRADE_ERROR),ERROR_GROUP:@(WX_NET)},
                 
-                
@(WX_KEY_EXCEPTION_ABILITY_DOWN):@{ERROR_TYPE:@(NATIVE_ERROR),ERROR_GROUP:@(NATIVE)},
-                
@(WX_KEY_EXCEPTION_ABILITY_DOWN_IMAGE):@{ERROR_TYPE:@(NATIVE_ERROR),ERROR_GROUP:@(NATIVE)},
-                
@(WX_KEY_EXCEPTION_ABILITY_DOWN_TOH5):@{ERROR_TYPE:@(NATIVE_ERROR),ERROR_GROUP:@(NATIVE)},
-                
@(WX_ERR_JSFRAMEWORK_START):@{ERROR_TYPE:@(NATIVE_ERROR),ERROR_GROUP:@(NATIVE)},
-                
@(WX_KEY_EXCEPTION_ABILITY_DOWN_):@{ERROR_TYPE:@(NATIVE_ERROR),ERROR_GROUP:@(NATIVE)},
-                
@(WX_KEY_EXCEPTION_EMPTY_SCREEN_JS):@{ERROR_TYPE:@(RENDER_ERROR),ERROR_GROUP:@(JS)}
+                
@(WX_KEY_EXCEPTION_ABILITY_DOWN):@{ERROR_TYPE:@(WX_NATIVE_ERROR),ERROR_GROUP:@(WX_NATIVE)},
+                
@(WX_KEY_EXCEPTION_ABILITY_DOWN_IMAGE):@{ERROR_TYPE:@(WX_NATIVE_ERROR),ERROR_GROUP:@(WX_NATIVE)},
+                
@(WX_KEY_EXCEPTION_ABILITY_DOWN_TOH5):@{ERROR_TYPE:@(WX_NATIVE_ERROR),ERROR_GROUP:@(WX_NATIVE)},
+                
@(WX_ERR_JSFRAMEWORK_START):@{ERROR_TYPE:@(WX_NATIVE_ERROR),ERROR_GROUP:@(WX_NATIVE)},
+                
@(WX_KEY_EXCEPTION_ABILITY_DOWN_):@{ERROR_TYPE:@(WX_NATIVE_ERROR),ERROR_GROUP:@(WX_NATIVE)},
+                
@(WX_KEY_EXCEPTION_EMPTY_SCREEN_JS):@{ERROR_TYPE:@(WX_RENDER_ERROR),ERROR_GROUP:@(WX_JS)}
                 };
     });
     return codeMap;
 }
 
++ (NSString *) convertTypeToStringName:(WXSDKErrorType)type
+{
+    switch (type) {
+        case WX_JS_ERROR:
+            return WX_ERROR_TYPE_JS;
+        case WX_RENDER_ERROR:
+            return WX_ERROR_TYPE_RENDER;
+        case WX_DEGRADE_ERROR:
+            return WX_ERROR_TYPE_DEGRADE;
+        case WX_NATIVE_ERROR:
+        default:
+            return WX_ERROR_TYPE_NATIVE;
+    }
+}
+
++ (NSString *) convertGroupToStringName:(WXSDKErrorGroup)group
+{
+    switch (group) {
+        case WX_JS:
+            return WX_ERROR_GROUP_JS;
+        case WX_NET:
+            return WX_ERROR_GROUP_NET;
+        case WX_NATIVE:
+        default:
+            return WX_ERROR_GROUP_NATIVE;
+    }
+}
+
 @end
diff --git a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m 
b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
index 7855f50acb..30b717b8d5 100644
--- a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
+++ b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
@@ -461,8 +461,15 @@ - (void)_renderWithRequest:(WXResourceRequest *)request 
options:(NSDictionary *)
 
         WX_MONITOR_FAIL_ON_PAGE(WXMTJSDownload, wxErrorCode, errorMessage, 
weakSelf.pageName);
         
+    
+        NSMutableDictionary *allUserInfo = [[NSMutableDictionary alloc] 
initWithDictionary:error.userInfo];
+        [allUserInfo addEntriesFromDictionary:loadError.userInfo];
+        NSError *errorWithReportMsg = [NSError errorWithDomain:error.domain
+                                             code:error.code
+                                         userInfo:allUserInfo];
+      
         if (weakSelf.onFailed) {
-            weakSelf.onFailed(error);
+            weakSelf.onFailed(errorWithReportMsg);
         }
         [weakSelf.apmInstance setProperty:KEY_PROPERTIES_ERROR_CODE 
withValue:[@(wxErrorCode) stringValue]];
     };
diff --git a/ios/sdk/WeexSDK/Sources/Protocol/WXApmProtocol.h 
b/ios/sdk/WeexSDK/Sources/Protocol/WXApmProtocol.h
index a461edbc9f..29316f505a 100644
--- a/ios/sdk/WeexSDK/Sources/Protocol/WXApmProtocol.h
+++ b/ios/sdk/WeexSDK/Sources/Protocol/WXApmProtocol.h
@@ -1,6 +1,5 @@
 
 #import <Foundation/Foundation.h>
-#import "WXAppMonitorProtocol.h"
 
 
 @protocol WXApmProtocol <NSObject>


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> [iOS] fix degrade_error not report 
> -----------------------------------
>
>                 Key: WEEX-569
>                 URL: https://issues.apache.org/jira/browse/WEEX-569
>             Project: Weex
>          Issue Type: Bug
>          Components: iOS
>            Reporter: peihan
>            Assignee: XuYouyang
>            Priority: Major
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to