From 240ad1cca64d16075b6c93c37d8f8658bcec6db3 Mon Sep 17 00:00:00 2001 From: Johann150 Date: Sun, 30 Oct 2022 16:22:12 +0100 Subject: [PATCH] server: fix ReferenceError The super constructor has to be called before accessing this. --- packages/backend/src/server/api/error.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/backend/src/server/api/error.ts b/packages/backend/src/server/api/error.ts index b93f5a2d2..c17a34e38 100644 --- a/packages/backend/src/server/api/error.ts +++ b/packages/backend/src/server/api/error.ts @@ -9,15 +9,14 @@ export class ApiError extends Error { info?: any | null, ) { if (!(code in errors)) { - this.info = `Unknown error "${code}" occurred.`; - this.code = 'INTERNAL_ERROR'; - } else { - this.info = info; - this.code = code; + info = `Unknown error "${code}" occurred.`; + code = 'INTERNAL_ERROR'; } const { message, httpStatusCode } = errors[this.code]; super(message); + this.code = code; + this.info = info; this.message = message; this.httpStatusCode = httpStatusCode; }