瀏覽代碼

ios: log fatal errors, don't swallow exceptions

master
Saúl Ibarra Corretgé 6 年之前
父節點
當前提交
f2fdef8361
共有 3 個檔案被更改,包括 11 行新增13 行删除
  1. 3
    0
      ios/sdk/src/JitsiMeet.m
  2. 1
    0
      ios/sdk/src/ReactUtils.h
  3. 7
    13
      ios/sdk/src/ReactUtils.m

+ 3
- 0
ios/sdk/src/JitsiMeet.m 查看文件

51
 
51
 
52
         // Register a fatal error handler for React.
52
         // Register a fatal error handler for React.
53
         registerReactFatalErrorHandler();
53
         registerReactFatalErrorHandler();
54
+
55
+        // Register a log handler for React.
56
+        registerReactLogHanler();
54
     }
57
     }
55
 
58
 
56
     return self;
59
     return self;

+ 1
- 0
ios/sdk/src/ReactUtils.h 查看文件

19
 
19
 
20
 NSMutableDictionary* mergeProps(NSDictionary *a, NSDictionary *b);
20
 NSMutableDictionary* mergeProps(NSDictionary *a, NSDictionary *b);
21
 void registerReactFatalErrorHandler(void);
21
 void registerReactFatalErrorHandler(void);
22
+void registerReactLogHandler(void);
22
 
23
 
23
 #endif /* JM_REACTUTILS_H */
24
 #endif /* JM_REACTUTILS_H */

+ 7
- 13
ios/sdk/src/ReactUtils.m 查看文件

15
  */
15
  */
16
 
16
 
17
 #import <React/RCTAssert.h>
17
 #import <React/RCTAssert.h>
18
+#import <React/RCTLog.h>
18
 
19
 
20
+#import "LogUtils.h"
19
 #import "ReactUtils.h"
21
 #import "ReactUtils.h"
20
 
22
 
21
 #pragma mark - Utility functions
23
 #pragma mark - Utility functions
67
  */
69
  */
68
 RCTFatalHandler _RCTFatal = ^(NSError *error) {
70
 RCTFatalHandler _RCTFatal = ^(NSError *error) {
69
     id jsStackTrace = error.userInfo[RCTJSStackTraceKey];
71
     id jsStackTrace = error.userInfo[RCTJSStackTraceKey];
70
-    @try {
71
-        NSString *name
72
-        = [NSString stringWithFormat:@"%@: %@",
73
-           RCTFatalExceptionName,
74
-           error.localizedDescription];
75
-        NSString *message
76
-        = RCTFormatError(error.localizedDescription, jsStackTrace, 75);
77
-        [NSException raise:name format:@"%@", message];
78
-    } @catch (NSException *e) {
79
-        if (!jsStackTrace) {
80
-            @throw;
81
-        }
82
-    }
72
+    NSString *name
73
+        = [NSString stringWithFormat:@"%@: %@", RCTFatalExceptionName, error.localizedDescription];
74
+    NSString *message
75
+        = RCTFormatError(error.localizedDescription, jsStackTrace, -1);
76
+    DDLogError(@"FATAL ERROR: %@\n%@", name, message);
83
 };
77
 };
84
 
78
 
85
 /**
79
 /**

Loading…
取消
儲存