Skip to content

Commit

Permalink
3/n Easy: Add MC to gate parsing unhandled JS errors in C++
Browse files Browse the repository at this point in the history
Summary:
Changelog:
[Internal][ErrorHandling] 3/n Add a gate for parsing unhandled JS errors in C++

Gate this just in case it causes issues. Enabling this is definitely a better behavior than before, because we want the JS stack when there is a JS error, not the native stack.

Reviewed By: sammy-SC

Differential Revision: D40397393

fbshipit-source-id: 586b4d7bcf710edb048b5c643646ba2f3c4c302a
  • Loading branch information
p-sun authored and facebook-github-bot committed Oct 18, 2022
1 parent b51a350 commit afb124d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions React/Base/RCTConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,9 @@ RCT_EXTERN void RCTSetValidateCanSendEventInRCTEventEmitter(BOOL value);
*/
RCT_EXTERN BOOL RCTGetMemoryPressureUnloadLevel(void);
RCT_EXTERN void RCTSetMemoryPressureUnloadLevel(int value);

/*
* Parse JS stack for unhandled JS errors caught in C++
*/
RCT_EXTERN BOOL RCTGetParseUnhandledJSErrorStackNatively(void);
RCT_EXTERN void RCTSetParseUnhandledJSErrorStackNatively(BOOL value);
16 changes: 16 additions & 0 deletions React/Base/RCTConstants.m
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,19 @@ void RCTSetMemoryPressureUnloadLevel(int value)
{
RCTMemoryPressureUnloadLevel = value;
}

/*
* In Bridge mode, parse the JS stack for unhandled JS errors, to display in RedBox.
* When false (previous default behavior), a native stack is displayed in the RedBox.
*/
static BOOL RCTParseUnhandledJSErrorStackNatively = NO;

BOOL RCTGetParseUnhandledJSErrorStackNatively()
{
return RCTParseUnhandledJSErrorStackNatively;
}

void RCTSetParseUnhandledJSErrorStackNatively(BOOL value)
{
RCTParseUnhandledJSErrorStackNatively = value;
}

0 comments on commit afb124d

Please sign in to comment.