Переглянути джерело

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,6 +51,9 @@
51 51
 
52 52
         // Register a fatal error handler for React.
53 53
         registerReactFatalErrorHandler();
54
+
55
+        // Register a log handler for React.
56
+        registerReactLogHanler();
54 57
     }
55 58
 
56 59
     return self;

+ 1
- 0
ios/sdk/src/ReactUtils.h Переглянути файл

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

+ 7
- 13
ios/sdk/src/ReactUtils.m Переглянути файл

@@ -15,7 +15,9 @@
15 15
  */
16 16
 
17 17
 #import <React/RCTAssert.h>
18
+#import <React/RCTLog.h>
18 19
 
20
+#import "LogUtils.h"
19 21
 #import "ReactUtils.h"
20 22
 
21 23
 #pragma mark - Utility functions
@@ -67,19 +69,11 @@ NSMutableDictionary* mergeProps(NSDictionary *a, NSDictionary *b) {
67 69
  */
68 70
 RCTFatalHandler _RCTFatal = ^(NSError *error) {
69 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
 /**

Завантаження…
Відмінити
Зберегти