From e02c051e19e538dd7d557820576d5d88e4b650fa Mon Sep 17 00:00:00 2001 From: Marc Rousavy Date: Wed, 31 Mar 2021 16:01:46 +0200 Subject: [PATCH] Override CameraError toString --- src/CameraError.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/CameraError.ts b/src/CameraError.ts index 589d9a6..926689c 100644 --- a/src/CameraError.ts +++ b/src/CameraError.ts @@ -116,11 +116,17 @@ class CameraError extends Error { * @internal */ constructor(code: TCode, message: string, cause?: ErrorWithCause) { - super(`[${code}]: ${message}${cause ? ` (Cause: ${cause.message})` : ''}`); + super(`[${code}]: ${message}${cause != null ? ` (Cause: ${cause.message})` : ''}`); + super.name = code; + super.message = message; this._code = code; this._message = message; this._cause = cause; } + + public toString(): string { + return `[${this.code}]: ${this.message}`; + } } /**