mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
earlyjs: Make ExceptionsManager the js interface for c++ pipeline (#47165)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/47165 The c++ pipeline needs a javascript interface. We could just re-use exceptions manager (for now). Changelog: [Internal] Reviewed By: javache Differential Revision: D64779068 fbshipit-source-id: 4e300668a01fa22e194ea9f149ef1d936d5e0834
This commit is contained in:
committed by
Facebook GitHub Bot
parent
2247e0b983
commit
0941b51e9d
+21
-18
@@ -141,24 +141,27 @@ let inExceptionHandler = false;
|
||||
* Logs exceptions to the (native) console and displays them
|
||||
*/
|
||||
function handleException(e: mixed, isFatal: boolean) {
|
||||
let error: Error;
|
||||
if (e instanceof Error) {
|
||||
error = e;
|
||||
} else {
|
||||
// Workaround for reporting errors caused by `throw 'some string'`
|
||||
// Unfortunately there is no way to figure out the stacktrace in this
|
||||
// case, so if you ended up here trying to trace an error, look for
|
||||
// `throw '<error message>'` somewhere in your codebase.
|
||||
error = new SyntheticError(e);
|
||||
}
|
||||
try {
|
||||
inExceptionHandler = true;
|
||||
/* $FlowFixMe[class-object-subtyping] added when improving typing for this
|
||||
* parameters */
|
||||
// $FlowFixMe[incompatible-call]
|
||||
reportException(error, isFatal, /*reportToConsole*/ true);
|
||||
} finally {
|
||||
inExceptionHandler = false;
|
||||
// TODO(T196834299): We should really use a c++ turbomodule for this
|
||||
if (!global.RN$handleException || !global.RN$handleException(e, isFatal)) {
|
||||
let error: Error;
|
||||
if (e instanceof Error) {
|
||||
error = e;
|
||||
} else {
|
||||
// Workaround for reporting errors caused by `throw 'some string'`
|
||||
// Unfortunately there is no way to figure out the stacktrace in this
|
||||
// case, so if you ended up here trying to trace an error, look for
|
||||
// `throw '<error message>'` somewhere in your codebase.
|
||||
error = new SyntheticError(e);
|
||||
}
|
||||
try {
|
||||
inExceptionHandler = true;
|
||||
/* $FlowFixMe[class-object-subtyping] added when improving typing for this
|
||||
* parameters */
|
||||
// $FlowFixMe[incompatible-call]
|
||||
reportException(error, isFatal, /*reportToConsole*/ true);
|
||||
} finally {
|
||||
inExceptionHandler = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,13 +21,7 @@ ExceptionsManager.installConsoleErrorReporter();
|
||||
if (!global.__fbDisableExceptionsManager) {
|
||||
const handleError = (e: mixed, isFatal: boolean) => {
|
||||
try {
|
||||
// TODO(T196834299): We should really use a c++ turbomodule for this
|
||||
if (
|
||||
!global.RN$handleException ||
|
||||
!global.RN$handleException(e, isFatal)
|
||||
) {
|
||||
ExceptionsManager.handleException(e, isFatal);
|
||||
}
|
||||
ExceptionsManager.handleException(e, isFatal);
|
||||
} catch (ee) {
|
||||
console.log('Failed to print error: ', ee.message);
|
||||
throw e;
|
||||
|
||||
Reference in New Issue
Block a user