mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-09 04:08:11 +08:00
Summary: Update Flow version in xplat (https://our.intern.facebook.com/intern/wiki/Flow/Flow_Release_Process/#update-xplat-js) allow-large-files bypass-lint Reviewed By: nmote Differential Revision: D14317820 fbshipit-source-id: 07ec22c0745321db036f4e10a502009a4b640652
43 lines
860 B
JavaScript
43 lines
860 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';
|
|
|
|
export type StackFrame = {
|
|
column: ?number,
|
|
file: string,
|
|
lineNumber: number,
|
|
methodName: string,
|
|
};
|
|
|
|
export type ExtendedError = Error & {
|
|
framesToPop?: number,
|
|
jsEngine?: string,
|
|
};
|
|
|
|
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);
|
|
|
|
let framesToPop = typeof e.framesToPop === 'number' ? e.framesToPop : 0;
|
|
while (framesToPop--) {
|
|
stack.shift();
|
|
}
|
|
return stack;
|
|
}
|
|
|
|
module.exports = parseErrorStack;
|