Skip to content

Commit

Permalink
fix getErrorTrace
Browse files Browse the repository at this point in the history
fix Cannot read properties of undefined (reading 'map') at prettyFormatErrorObj .
fullstack-build#311
  • Loading branch information
Lyoko-Jeremie authored Dec 23, 2024
1 parent 9a5d156 commit 99bce34
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/runtime/nodejs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ export function getCallerStackFrame(stackDepthLevel: number, error: Error = Erro
}

export function getErrorTrace(error: Error): IStackFrame[] {
return (error as Error)?.stack?.split("\n")?.reduce((result: IStackFrame[], line: string) => {
return ((error as Error)?.stack?.split("\n") ?? []).reduce((result: IStackFrame[], line: string) => {
if (line.includes(" at ")) {
result.push(stackLineToStackFrame(line));
}
return result;
}, []) as IStackFrame[];
}, []);
}

function stackLineToStackFrame(line?: string): IStackFrame {
Expand Down

0 comments on commit 99bce34

Please sign in to comment.