From afb124dcf0cdf0db525acc7cfd2cea2742c64068 Mon Sep 17 00:00:00 2001 From: Paige Sun Date: Tue, 18 Oct 2022 15:09:23 -0700 Subject: [PATCH] 3/n Easy: Add MC to gate parsing unhandled JS errors in C++ 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 --- React/Base/RCTConstants.h | 6 ++++++ React/Base/RCTConstants.m | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/React/Base/RCTConstants.h b/React/Base/RCTConstants.h index f199450a4c9..217b7aabc21 100644 --- a/React/Base/RCTConstants.h +++ b/React/Base/RCTConstants.h @@ -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); diff --git a/React/Base/RCTConstants.m b/React/Base/RCTConstants.m index d0bf96dc27c..03e5ffe984c 100644 --- a/React/Base/RCTConstants.m +++ b/React/Base/RCTConstants.m @@ -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; +}