mirror of
https://activitypub.software/TransFem-org/Sharkey.git
synced 2024-12-16 10:11:54 +01:00
24645e3d3d
* enhance(backend): ActivityPub 周りで HTTP 429 Too Many Requests を受け取った際にリトライするように * add to changelog --------- Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
20 lines
657 B
TypeScript
20 lines
657 B
TypeScript
/*
|
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
export class StatusError extends Error {
|
|
public statusCode: number;
|
|
public statusMessage?: string;
|
|
public isClientError: boolean;
|
|
public isRetryable: boolean;
|
|
|
|
constructor(message: string, statusCode: number, statusMessage?: string) {
|
|
super(message);
|
|
this.name = 'StatusError';
|
|
this.statusCode = statusCode;
|
|
this.statusMessage = statusMessage;
|
|
this.isClientError = typeof this.statusCode === 'number' && this.statusCode >= 400 && this.statusCode < 500;
|
|
this.isRetryable = !this.isClientError || this.statusCode === 429;
|
|
}
|
|
}
|