Skip to content

Commit 7893b4d

Browse files
committed
fix: Fix instanceof operator for error classes
1 parent 81afb29 commit 7893b4d

14 files changed

+19
-3
lines changed

Diff for: src/errors/masto-deserialize-error.ts

+1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ export class MastoDeserializeError extends MastoError {
1414
props?: MastoErrorProps,
1515
) {
1616
super(message, props);
17+
Object.setPrototypeOf(this, MastoDeserializeError.prototype);
1718
}
1819
}

Diff for: src/errors/masto-error.ts

+2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ export abstract class MastoError extends Error {
4343
*/
4444
constructor(message: string, props: MastoErrorProps = {}) {
4545
super(message, { cause: props.cause });
46+
Object.setPrototypeOf(this, MastoError.prototype);
47+
4648
this.description = props.description;
4749
this.details = props.details;
4850
}

Diff for: src/errors/masto-http-conflict-error.ts

+1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ export class MastoHttpConflictError extends MastoHttpError {
99

1010
constructor(message: string, props?: MastoErrorProps) {
1111
super(message, 409, props);
12+
Object.setPrototypeOf(this, MastoHttpConflictError.prototype);
1213
}
1314
}

Diff for: src/errors/masto-http-error.ts

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export abstract class MastoHttpError extends MastoError {
77

88
constructor(message: string, statusCode: number, props?: MastoErrorProps) {
99
super(message, props);
10+
Object.setPrototypeOf(this, MastoHttpError.prototype);
1011
this.statusCode = statusCode;
1112
}
1213
}

Diff for: src/errors/masto-http-forbidden-error.ts

+1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ export class MastoHttpForbiddenError extends MastoHttpError {
99

1010
constructor(message: string, props?: MastoErrorProps) {
1111
super(message, 403, props);
12+
Object.setPrototypeOf(this, MastoHttpForbiddenError.prototype);
1213
}
1314
}

Diff for: src/errors/masto-http-gone-error.ts

+1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ export class MastoHttpGoneError extends MastoHttpError {
99

1010
constructor(message: string, props?: MastoErrorProps) {
1111
super(message, 410, props);
12+
Object.setPrototypeOf(this, MastoHttpGoneError.prototype);
1213
}
1314
}

Diff for: src/errors/masto-http-not-found-error.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ import { MastoHttpError } from './masto-http-error';
55
* Mastodon not found error class
66
*/
77
export class MastoHttpNotFoundError extends MastoHttpError {
8-
override name = 'MastoNotFoundError';
8+
override name = 'MastoHttpNotFoundError';
99

1010
constructor(message: string, props?: MastoErrorProps) {
1111
super(message, 404, props);
12+
Object.setPrototypeOf(this, MastoHttpNotFoundError.prototype);
1213
}
1314
}

Diff for: src/errors/masto-http-rate-limit-error.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export type MastoRateLimitErrorProps = MastoErrorProps & {
1111
* Mastodon rate limit error class
1212
*/
1313
export class MastoHttpRateLimitError extends MastoHttpError {
14-
override name = 'MastoRateLimitError';
14+
override name = 'MastoHttpRateLimitError';
1515

1616
/** Number of requests permitted per time period */
1717
readonly limit: number;
@@ -22,6 +22,8 @@ export class MastoHttpRateLimitError extends MastoHttpError {
2222

2323
constructor(message: string, props: MastoRateLimitErrorProps) {
2424
super(message, 429, props);
25+
Object.setPrototypeOf(this, MastoHttpRateLimitError.prototype);
26+
2527
this.limit = props?.limit;
2628
this.remaining = props?.remaining;
2729
this.reset = props?.reset;

Diff for: src/errors/masto-http-unauthorized-error.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ import { MastoHttpError } from './masto-http-error';
55
* Mastodon unauthorized error class
66
*/
77
export class MastoHttpUnauthorizedError extends MastoHttpError {
8-
override name = 'MastoUnauthorizedError';
8+
override name = 'MastoHttpUnauthorizedError';
99

1010
constructor(message: string, props: MastoErrorProps) {
1111
super(message, 401, props);
12+
Object.setPrototypeOf(this, MastoHttpUnauthorizedError.prototype);
1213
}
1314
}

Diff for: src/errors/masto-http-unexpected-error.ts

+1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ export class MastoHttpUnexpectedError extends MastoHttpError {
66

77
constructor(message: string, statusCode: number, props?: MastoErrorProps) {
88
super(message, statusCode, props);
9+
Object.setPrototypeOf(this, MastoHttpUnexpectedError.prototype);
910
}
1011
}

Diff for: src/errors/masto-http-unprocessable-entity-error.ts

+1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ export class MastoHttpUnprocessableEntityError extends MastoHttpError {
99

1010
constructor(message: string, props: MastoErrorProps) {
1111
super(message, 422, props);
12+
Object.setPrototypeOf(this, MastoHttpUnprocessableEntityError.prototype);
1213
}
1314
}

Diff for: src/errors/masto-timeout-error.ts

+1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ export class MastoTimeoutError extends MastoError {
99

1010
constructor(message: string, props?: MastoErrorProps) {
1111
super(message, props);
12+
Object.setPrototypeOf(this, MastoTimeoutError.prototype);
1213
}
1314
}

Diff for: src/errors/masto-unexpected-error.ts

+1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ export class MastoUnexpectedError extends MastoError {
66

77
constructor(message: string, props: MastoErrorProps = {}) {
88
super(message, { cause: props.cause });
9+
Object.setPrototypeOf(this, MastoUnexpectedError.prototype);
910
}
1011
}

Diff for: src/errors/masto-version-error.ts

+1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ export class MastoVersionError extends MastoError {
99

1010
constructor(message: string, props?: MastoErrorProps) {
1111
super(message, props);
12+
Object.setPrototypeOf(this, MastoVersionError.prototype);
1213
}
1314
}

0 commit comments

Comments
 (0)