server: fix ReferenceError

The super constructor has to be called before accessing this.
This commit is contained in:
Johann150 2022-10-30 16:22:12 +01:00
parent eb1ecd90e6
commit 240ad1cca6
Signed by untrusted user: Johann150
GPG key ID: 9EE6577A2A06F8F1

View file

@ -9,15 +9,14 @@ export class ApiError extends Error {
info?: any | null, info?: any | null,
) { ) {
if (!(code in errors)) { if (!(code in errors)) {
this.info = `Unknown error "${code}" occurred.`; info = `Unknown error "${code}" occurred.`;
this.code = 'INTERNAL_ERROR'; code = 'INTERNAL_ERROR';
} else {
this.info = info;
this.code = code;
} }
const { message, httpStatusCode } = errors[this.code]; const { message, httpStatusCode } = errors[this.code];
super(message); super(message);
this.code = code;
this.info = info;
this.message = message; this.message = message;
this.httpStatusCode = httpStatusCode; this.httpStatusCode = httpStatusCode;
} }