Skip to content

Commit

Permalink
Repair when RCTRedBoxGetEnabled is false , inoperative in RCTExceptio…
Browse files Browse the repository at this point in the history
…nsManager
  • Loading branch information
liamxujia committed Dec 6, 2022
1 parent 96d6680 commit 4f5bf74
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions React/CoreModules/RCTExceptionsManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#import <React/RCTDefines.h>
#import <React/RCTLog.h>
#import <React/RCTRedBox.h>
#import <React/RCTRedBoxSetEnabled.h>
#import <React/RCTReloadCommand.h>
#import <React/RCTRootView.h>

Expand Down Expand Up @@ -40,8 +41,10 @@ - (void)reportSoft:(NSString *)message
exceptionId:(double)exceptionId
extraDataAsJSON:(nullable NSString *)extraDataAsJSON
{
RCTRedBox *redbox = [_moduleRegistry moduleForName:"RedBox"];
[redbox showErrorMessage:message withStack:stack errorCookie:(int)exceptionId];
if (RCTRedBoxGetEnabled()) {
RCTRedBox *redbox = [_moduleRegistry moduleForName:"RedBox"];
[redbox showErrorMessage:message withStack:stack errorCookie:(int)exceptionId];
}

if (_delegate) {
[_delegate handleSoftJSExceptionWithMessage:message
Expand All @@ -56,8 +59,10 @@ - (void)reportFatal:(NSString *)message
exceptionId:(double)exceptionId
extraDataAsJSON:(nullable NSString *)extraDataAsJSON
{
RCTRedBox *redbox = [_moduleRegistry moduleForName:"RedBox"];
[redbox showErrorMessage:message withStack:stack errorCookie:(int)exceptionId];
if (RCTRedBoxGetEnabled()) {
RCTRedBox *redbox = [_moduleRegistry moduleForName:"RedBox"];
[redbox showErrorMessage:message withStack:stack errorCookie:(int)exceptionId];
}

if (_delegate) {
[_delegate handleFatalJSExceptionWithMessage:message
Expand Down Expand Up @@ -99,8 +104,10 @@ - (void)reportFatal:(NSString *)message
: (NSArray<NSDictionary *> *)stack exceptionId
: (double)exceptionId)
{
RCTRedBox *redbox = [_moduleRegistry moduleForName:"RedBox"];
[redbox updateErrorMessage:message withStack:stack errorCookie:(int)exceptionId];
if (RCTRedBoxGetEnabled()) {
RCTRedBox *redbox = [_moduleRegistry moduleForName:"RedBox"];
[redbox updateErrorMessage:message withStack:stack errorCookie:(int)exceptionId];
}

if (_delegate && [_delegate respondsToSelector:@selector(updateJSExceptionWithMessage:stack:exceptionId:)]) {
[_delegate updateJSExceptionWithMessage:message stack:stack exceptionId:[NSNumber numberWithDouble:exceptionId]];
Expand Down

0 comments on commit 4f5bf74

Please sign in to comment.