mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Only pass Error.stack to parseErrorStack
Summary: I want to be able parse error stacks in contexts where I have a call stack string but no error object. This diff changes parseErrorStack to only accept the stack, instead of a whole error object. Changelog: [Internal] Reviewed By: motiz88 Differential Revision: D22752048 fbshipit-source-id: b4b1cd58802eefe736130d48a82bc091241a11ee
This commit is contained in:
committed by
Facebook GitHub Bot
parent
cd6e2b468d
commit
9edfc43aad
@@ -47,22 +47,22 @@ function convertHermesStack(stack: HermesParsedStack): Array<StackFrame> {
|
||||
return frames;
|
||||
}
|
||||
|
||||
function parseErrorStack(e: ExtendedError): Array<StackFrame> {
|
||||
if (!e || !e.stack) {
|
||||
function parseErrorStack(errorStack?: string): Array<StackFrame> {
|
||||
if (errorStack == null) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const stacktraceParser = require('stacktrace-parser');
|
||||
const stack = Array.isArray(e.stack)
|
||||
? e.stack
|
||||
const parsedStack = Array.isArray(errorStack)
|
||||
? errorStack
|
||||
: global.HermesInternal
|
||||
? convertHermesStack(parseHermesStack(e.stack))
|
||||
: stacktraceParser.parse(e.stack).map(frame => ({
|
||||
? convertHermesStack(parseHermesStack(errorStack))
|
||||
: stacktraceParser.parse(errorStack).map(frame => ({
|
||||
...frame,
|
||||
column: frame.column != null ? frame.column - 1 : null,
|
||||
}));
|
||||
|
||||
return stack;
|
||||
return parsedStack;
|
||||
}
|
||||
|
||||
module.exports = parseErrorStack;
|
||||
|
||||
Reference in New Issue
Block a user