From fc197630beb03ecca7aaef2072b9f3ddb20212fe Mon Sep 17 00:00:00 2001 From: John Lees-Miller Date: Tue, 5 May 2020 09:02:11 +0100 Subject: [PATCH] Avoid capturing stack trace twice Co-authored-by: Eric Mc Sween --- libraries/o-error/index.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libraries/o-error/index.js b/libraries/o-error/index.js index c7a036bd2f..3eadfc83de 100644 --- a/libraries/o-error/index.js +++ b/libraries/o-error/index.js @@ -54,10 +54,14 @@ class OError extends Error { if (!oError._oErrorTags) oError._oErrorTags = [] - const tag = new TaggedError(message, info) - - // Hide this function in the stack trace. - if (Error.captureStackTrace) Error.captureStackTrace(tag, OError.tag) + let tag + if (Error.captureStackTrace) { + // Hide this function in the stack trace. + tag = { name: 'TaggedError', message, info } + Error.captureStackTrace(tag, OError.tag) + } else { + tag = new TaggedError(message, info) + } oError._oErrorTags.push(tag)