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,
) {
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;
}