From 37b00fd7725a2b80de223d65d4702bfbcad4c234 Mon Sep 17 00:00:00 2001 From: Fabian Stamm Date: Sun, 4 Nov 2018 20:34:36 +0100 Subject: [PATCH] Fixing error on getCallerFromExisting when invalid error --- src/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/index.ts b/src/index.ts index d3c1786..2a15bb2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -426,6 +426,7 @@ function getCallerFile() { } function getCallerFromExisting(err: Error): { file: string, line: number } { + if (!err || !err.stack) return { file: "NOFILE", line: 0 }; let lines = err.stack.split("\n"); let current = path.basename(__filename); lines.shift();// removing first line