Files
summaly/src/utils/status-error.ts
tamaina 709ca51b6c v3.0.3
2023-02-12 14:37:37 +00:00

15 lines
471 B
TypeScript

export class StatusError extends Error {
public name: string;
public statusCode: number;
public statusMessage?: string;
public isPermanentError: boolean;
constructor(message: string, statusCode: number, statusMessage?: string) {
super(message);
this.name = 'StatusError';
this.statusCode = statusCode;
this.statusMessage = statusMessage;
this.isPermanentError = typeof this.statusCode === 'number' && this.statusCode >= 400 && this.statusCode < 500;
}
}