summaryrefslogtreecommitdiff
path: root/packages/backend/src/misc/status-error.ts
blob: 0a33f8acaf9a9191e0159fc432e5775d0e0bd687 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
export class StatusError extends Error {
	public statusCode: number;
	public statusMessage?: string;
	public isClientError: 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;
	}
}