From: Jérôme Benoit Date: Sun, 28 Jan 2024 14:34:06 +0000 (+0100) Subject: refactor: use Error static function to generate BaseError stack trace X-Git-Tag: v1.2.33~15 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=2ebd83d0686b06cfade9322a2d94210774c6ea34;p=e-mobility-charging-stations-simulator.git refactor: use Error static function to generate BaseError stack trace Signed-off-by: Jérôme Benoit --- diff --git a/src/exception/BaseError.ts b/src/exception/BaseError.ts index 0f41c331..ce37fd98 100644 --- a/src/exception/BaseError.ts +++ b/src/exception/BaseError.ts @@ -1,10 +1,13 @@ export class BaseError extends Error { + public date: Date + public constructor (message?: string) { super(message) this.name = new.target.name + this.date = new Date() Object.setPrototypeOf(this, new.target.prototype) - if (this.stack == null && typeof BaseError.captureStackTrace === 'function') { - BaseError.captureStackTrace(this, this.constructor) + if (typeof Error.captureStackTrace === 'function') { + Error.captureStackTrace(this, BaseError) } } }