export class HttpStatusException extends Error { constructor(message: string, private code: number) { super(message); } public get statusCode(): number { return this.code; } public get statusText(): string { return HttpStatusException.getStatusText(this.code); } public static getStatusText(code): string { switch (code) { case 301: return 'Moved Permanently'; case 302: return 'Found'; case 307: return 'Temporary Redirect'; case 308: return 'Permanent Redirect'; case 400: return 'Bad Request'; case 401: return 'Unauthorized'; case 403: return 'Forbidden'; case 404: return 'Not Found'; case 405: return 'Method Not Allowed'; case 406: return 'Not Acceptable'; case 500: return 'Internal Server Error'; case 501: return 'Not Implemented'; case 502: return 'Bad Gateway'; case 503: return 'Service Unavailable'; default: return 'Unknown Error'; } } }