From 497f2a793634b4d6a0344f4e4a1ab5a9101c15d3 Mon Sep 17 00:00:00 2001 From: John Lees-Miller Date: Fri, 15 May 2020 11:07:08 +0100 Subject: [PATCH] Make tag check stricter and use a map --- libraries/o-error/index.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libraries/o-error/index.js b/libraries/o-error/index.js index fce23de2e0..1184fcfe35 100644 --- a/libraries/o-error/index.js +++ b/libraries/o-error/index.js @@ -108,10 +108,8 @@ class OError extends Error { let stack = oError.stack - if (oError._oErrorTags) { - for (const tag of oError._oErrorTags) { - stack += `\n${tag.stack}` - } + if (Array.isArray(oError._oErrorTags) && oError._oErrorTags.length) { + stack += `\n${oError._oErrorTags.map((tag) => tag.stack).join('\n')}` } const causeStack = oError.cause && OError.getFullStack(oError.cause)