From 9058e6a8305eab0539c1699d7fb0d5429929953f Mon Sep 17 00:00:00 2001 From: Bastien Caudan Date: Fri, 24 Apr 2020 13:02:14 +0200 Subject: [PATCH] pretty stacktrace: catch uncaught exception on node internal files --- src/processors/pretty-stacktrace-processor.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/processors/pretty-stacktrace-processor.ts b/src/processors/pretty-stacktrace-processor.ts index 520e7969..d7d08ca8 100644 --- a/src/processors/pretty-stacktrace-processor.ts +++ b/src/processors/pretty-stacktrace-processor.ts @@ -49,8 +49,13 @@ export class PrettyStacktraceProcessor extends DisplayProcessor { private retrieveErrorContext(filename: string, lineNb: number, columnNb: number) { const logs = []; - const fileLines = fs.readFileSync(filename, "utf-8") - .split("\n"); + let fileLines; + try { + fileLines = fs.readFileSync(filename, "utf-8") + .split("\n"); + } catch (error) { + return `jasmine-spec-reporter: unable to open '${filename}'\n${error}`; + } for (let i = 0; i < fileLines.length; i++) { const errorLine = lineNb - 1;