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}`; + } } /**