From 01298466b2c850e912a7ef91a8829f41b71a6450 Mon Sep 17 00:00:00 2001 From: Owen Pearson Date: Fri, 17 Feb 2023 11:42:36 +0000 Subject: [PATCH] fix: `ErrorInfo` extends `Error` --- src/common/lib/client/realtimechannel.ts | 6 +----- src/common/lib/types/errorinfo.ts | 3 ++- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/common/lib/client/realtimechannel.ts b/src/common/lib/client/realtimechannel.ts index 8bd065a1fa..6185bd017e 100644 --- a/src/common/lib/client/realtimechannel.ts +++ b/src/common/lib/client/realtimechannel.ts @@ -114,11 +114,7 @@ class RealtimeChannel extends Channel { } static invalidStateError(state: string): ErrorInfo { - return { - statusCode: 400, - code: 90001, - message: 'Channel operation failed as channel state is ' + state, - }; + return new ErrorInfo('Channel operation failed as channel state is ' + state, 90001, 400); } static processListenerArgs(args: unknown[]): any[] { diff --git a/src/common/lib/types/errorinfo.ts b/src/common/lib/types/errorinfo.ts index 913f7677f7..bcd7f91458 100644 --- a/src/common/lib/types/errorinfo.ts +++ b/src/common/lib/types/errorinfo.ts @@ -1,7 +1,7 @@ import Platform from 'common/platform'; import * as Utils from '../util/utils'; -export default class ErrorInfo { +export default class ErrorInfo extends Error { message: string; code: number | null; statusCode?: number; @@ -9,6 +9,7 @@ export default class ErrorInfo { href?: string; constructor(message: string, code: number | null, statusCode?: number, cause?: string | Error | ErrorInfo) { + super(message); this.message = message; this.code = code; this.statusCode = statusCode;