mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
5eddf1d79a
Summary: This diff adds error handling to logbox so that if there is an error either when parsing logs or when rendering LogBox, we show a native redbox with the error that was thrown and a message explaining that it's an internal React Native error. Changelog: [Internal] Reviewed By: cpojer Differential Revision: D18394788 fbshipit-source-id: 5d74d58e4b28ef6d863079e83677fb23ef4ccb34
36 lines
749 B
JavaScript
36 lines
749 B
JavaScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @format
|
|
* @flow
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
import type {StackFrame} from '../NativeExceptionsManager';
|
|
|
|
export type ExtendedError = Error & {
|
|
jsEngine?: string,
|
|
preventSymbolication?: boolean,
|
|
componentStack?: string,
|
|
forceRedbox?: boolean,
|
|
};
|
|
|
|
function parseErrorStack(e: ExtendedError): Array<StackFrame> {
|
|
if (!e || !e.stack) {
|
|
return [];
|
|
}
|
|
|
|
const stacktraceParser = require('stacktrace-parser');
|
|
const stack = Array.isArray(e.stack)
|
|
? e.stack
|
|
: stacktraceParser.parse(e.stack);
|
|
|
|
return stack;
|
|
}
|
|
|
|
module.exports = parseErrorStack;
|