mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Hook EarlyJsErrorHandler
Summary: Hoop up EarlyJsErrorHandler so we could pass js error data to object-c to report. Changelog: [iOS][Chagned] - Add function to report early js errors Reviewed By: RSNara Differential Revision: D34096343 fbshipit-source-id: fdbc6ea5d1f3cc6ab55fcd22b48bbe8fb1f1ca8f
This commit is contained in:
committed by
Facebook GitHub Bot
parent
325be429fd
commit
1804951595
@@ -6,8 +6,8 @@
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import <React/RCTBridgeModule.h>
|
||||
#import <string>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@@ -37,6 +37,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
- (void)reportFatalException:(nullable NSString *)message
|
||||
stack:(nullable NSArray<NSDictionary *> *)stack
|
||||
exceptionId:(double)exceptionId;
|
||||
- (void)reportEarlyJsException:(std::string)errorMap;
|
||||
|
||||
@property (nonatomic, weak) id<RCTExceptionsManagerDelegate> delegate;
|
||||
|
||||
|
||||
@@ -138,6 +138,27 @@ RCT_EXPORT_METHOD(reportException : (JS::NativeExceptionsManager::ExceptionData
|
||||
}
|
||||
}
|
||||
|
||||
- (void)reportEarlyJsException:(std::string)errorMap
|
||||
{
|
||||
NSString *errprStr = [NSString stringWithUTF8String:errorMap.c_str()];
|
||||
NSData *jsonData = [errprStr dataUsingEncoding:NSUTF8StringEncoding];
|
||||
NSError *jsonError;
|
||||
NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:jsonData
|
||||
options:NSJSONWritingPrettyPrinted
|
||||
error:&jsonError];
|
||||
|
||||
NSString *message = [dict objectForKey:@"message"];
|
||||
double exceptionId = [[dict objectForKey:@"id"] doubleValue];
|
||||
NSArray *stack = [dict objectForKey:@"stack"];
|
||||
BOOL isFatal = [[dict objectForKey:@"isFatal"] boolValue];
|
||||
|
||||
if (isFatal) {
|
||||
[self reportFatalException:message stack:stack exceptionId:exceptionId];
|
||||
} else {
|
||||
[self reportSoftException:message stack:stack exceptionId:exceptionId];
|
||||
}
|
||||
}
|
||||
|
||||
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
||||
(const facebook::react::ObjCTurboModule::InitParams &)params
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user