From 35efcc3a2921eebb5bcb1c00b95f656e1b777058 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 8 Feb 2022 14:39:12 +0100 Subject: [PATCH] Silence one code smell MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/exception/BaseError.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/exception/BaseError.ts b/src/exception/BaseError.ts index e1a82c00..ad78e261 100644 --- a/src/exception/BaseError.ts +++ b/src/exception/BaseError.ts @@ -3,6 +3,10 @@ export default class BaseError extends Error { super(message); this.name = new.target.name; Object.setPrototypeOf(this, new.target.prototype); - Error.captureStackTrace ? (Error.captureStackTrace(this, this.constructor)) : (this.stack = (new Error()).stack); + Error.captureStackTrace ? (Error.captureStackTrace(this, this.constructor)) : (this.createStack()); + } + + private createStack(): void { + this.stack = new Error().stack; } } -- 2.34.1