mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
75deeb32fe
Summary: The React team wants exceptions thrown during render to pop over the screen as fatals. Changelog: [Internal] Reviewed By: motiz88 Differential Revision: D18439258 fbshipit-source-id: dded7b9d93271c1a4eff682be521c7567dfe7d7e
37 lines
779 B
JavaScript
37 lines
779 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,
|
|
isComponentError?: 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;
|