diff --git a/src/errors/masto-deserialize-error.ts b/src/errors/masto-deserialize-error.ts index ca366c589..af11b7d36 100644 --- a/src/errors/masto-deserialize-error.ts +++ b/src/errors/masto-deserialize-error.ts @@ -14,5 +14,6 @@ export class MastoDeserializeError extends MastoError { props?: MastoErrorProps, ) { super(message, props); + Object.setPrototypeOf(this, MastoDeserializeError.prototype); } } diff --git a/src/errors/masto-error.ts b/src/errors/masto-error.ts index d12c06f1f..861e31020 100644 --- a/src/errors/masto-error.ts +++ b/src/errors/masto-error.ts @@ -43,6 +43,8 @@ export abstract class MastoError extends Error { */ constructor(message: string, props: MastoErrorProps = {}) { super(message, { cause: props.cause }); + Object.setPrototypeOf(this, MastoError.prototype); + this.description = props.description; this.details = props.details; } diff --git a/src/errors/masto-http-conflict-error.ts b/src/errors/masto-http-conflict-error.ts index eb8829f5d..19017e727 100644 --- a/src/errors/masto-http-conflict-error.ts +++ b/src/errors/masto-http-conflict-error.ts @@ -9,5 +9,6 @@ export class MastoHttpConflictError extends MastoHttpError { constructor(message: string, props?: MastoErrorProps) { super(message, 409, props); + Object.setPrototypeOf(this, MastoHttpConflictError.prototype); } } diff --git a/src/errors/masto-http-error.ts b/src/errors/masto-http-error.ts index 92e98e591..99103b09f 100644 --- a/src/errors/masto-http-error.ts +++ b/src/errors/masto-http-error.ts @@ -7,6 +7,7 @@ export abstract class MastoHttpError extends MastoError { constructor(message: string, statusCode: number, props?: MastoErrorProps) { super(message, props); + Object.setPrototypeOf(this, MastoHttpError.prototype); this.statusCode = statusCode; } } diff --git a/src/errors/masto-http-forbidden-error.ts b/src/errors/masto-http-forbidden-error.ts index 03b7b7d37..d1994d3f0 100644 --- a/src/errors/masto-http-forbidden-error.ts +++ b/src/errors/masto-http-forbidden-error.ts @@ -9,5 +9,6 @@ export class MastoHttpForbiddenError extends MastoHttpError { constructor(message: string, props?: MastoErrorProps) { super(message, 403, props); + Object.setPrototypeOf(this, MastoHttpForbiddenError.prototype); } } diff --git a/src/errors/masto-http-gone-error.ts b/src/errors/masto-http-gone-error.ts index a2380f6e3..bad7ad324 100644 --- a/src/errors/masto-http-gone-error.ts +++ b/src/errors/masto-http-gone-error.ts @@ -9,5 +9,6 @@ export class MastoHttpGoneError extends MastoHttpError { constructor(message: string, props?: MastoErrorProps) { super(message, 410, props); + Object.setPrototypeOf(this, MastoHttpGoneError.prototype); } } diff --git a/src/errors/masto-http-not-found-error.ts b/src/errors/masto-http-not-found-error.ts index 55a8c5bf1..ff3467111 100644 --- a/src/errors/masto-http-not-found-error.ts +++ b/src/errors/masto-http-not-found-error.ts @@ -5,9 +5,10 @@ import { MastoHttpError } from './masto-http-error'; * Mastodon not found error class */ export class MastoHttpNotFoundError extends MastoHttpError { - override name = 'MastoNotFoundError'; + override name = 'MastoHttpNotFoundError'; constructor(message: string, props?: MastoErrorProps) { super(message, 404, props); + Object.setPrototypeOf(this, MastoHttpNotFoundError.prototype); } } diff --git a/src/errors/masto-http-rate-limit-error.ts b/src/errors/masto-http-rate-limit-error.ts index 8836c0977..398581a00 100644 --- a/src/errors/masto-http-rate-limit-error.ts +++ b/src/errors/masto-http-rate-limit-error.ts @@ -11,7 +11,7 @@ export type MastoRateLimitErrorProps = MastoErrorProps & { * Mastodon rate limit error class */ export class MastoHttpRateLimitError extends MastoHttpError { - override name = 'MastoRateLimitError'; + override name = 'MastoHttpRateLimitError'; /** Number of requests permitted per time period */ readonly limit: number; @@ -22,6 +22,8 @@ export class MastoHttpRateLimitError extends MastoHttpError { constructor(message: string, props: MastoRateLimitErrorProps) { super(message, 429, props); + Object.setPrototypeOf(this, MastoHttpRateLimitError.prototype); + this.limit = props?.limit; this.remaining = props?.remaining; this.reset = props?.reset; diff --git a/src/errors/masto-http-unauthorized-error.ts b/src/errors/masto-http-unauthorized-error.ts index 45db9f1ae..796fbbaf6 100644 --- a/src/errors/masto-http-unauthorized-error.ts +++ b/src/errors/masto-http-unauthorized-error.ts @@ -5,9 +5,10 @@ import { MastoHttpError } from './masto-http-error'; * Mastodon unauthorized error class */ export class MastoHttpUnauthorizedError extends MastoHttpError { - override name = 'MastoUnauthorizedError'; + override name = 'MastoHttpUnauthorizedError'; constructor(message: string, props: MastoErrorProps) { super(message, 401, props); + Object.setPrototypeOf(this, MastoHttpUnauthorizedError.prototype); } } diff --git a/src/errors/masto-http-unexpected-error.ts b/src/errors/masto-http-unexpected-error.ts index 2e06e1058..7d0b53e85 100644 --- a/src/errors/masto-http-unexpected-error.ts +++ b/src/errors/masto-http-unexpected-error.ts @@ -6,5 +6,6 @@ export class MastoHttpUnexpectedError extends MastoHttpError { constructor(message: string, statusCode: number, props?: MastoErrorProps) { super(message, statusCode, props); + Object.setPrototypeOf(this, MastoHttpUnexpectedError.prototype); } } diff --git a/src/errors/masto-http-unprocessable-entity-error.ts b/src/errors/masto-http-unprocessable-entity-error.ts index 2604dcd4c..f9c22a37b 100644 --- a/src/errors/masto-http-unprocessable-entity-error.ts +++ b/src/errors/masto-http-unprocessable-entity-error.ts @@ -9,5 +9,6 @@ export class MastoHttpUnprocessableEntityError extends MastoHttpError { constructor(message: string, props: MastoErrorProps) { super(message, 422, props); + Object.setPrototypeOf(this, MastoHttpUnprocessableEntityError.prototype); } } diff --git a/src/errors/masto-timeout-error.ts b/src/errors/masto-timeout-error.ts index 763f79f7d..448271d76 100644 --- a/src/errors/masto-timeout-error.ts +++ b/src/errors/masto-timeout-error.ts @@ -9,5 +9,6 @@ export class MastoTimeoutError extends MastoError { constructor(message: string, props?: MastoErrorProps) { super(message, props); + Object.setPrototypeOf(this, MastoTimeoutError.prototype); } } diff --git a/src/errors/masto-unexpected-error.ts b/src/errors/masto-unexpected-error.ts index 22f94f2c7..2f5850ff2 100644 --- a/src/errors/masto-unexpected-error.ts +++ b/src/errors/masto-unexpected-error.ts @@ -6,5 +6,6 @@ export class MastoUnexpectedError extends MastoError { constructor(message: string, props: MastoErrorProps = {}) { super(message, { cause: props.cause }); + Object.setPrototypeOf(this, MastoUnexpectedError.prototype); } } diff --git a/src/errors/masto-version-error.ts b/src/errors/masto-version-error.ts index 31b19b755..3370314ea 100644 --- a/src/errors/masto-version-error.ts +++ b/src/errors/masto-version-error.ts @@ -9,5 +9,6 @@ export class MastoVersionError extends MastoError { constructor(message: string, props?: MastoErrorProps) { super(message, props); + Object.setPrototypeOf(this, MastoVersionError.prototype); } }