initial
[sketchy-heroes.git] / src / lib / http-errors.ts
1 export class HttpError extends Error {
2   statusCode: number;
3   errorCode: string;
4   constructor(msg: string, statusCode: number, errorCode: string) {
5     super(msg);
6     this.statusCode = statusCode;
7     this.errorCode = errorCode;
8   }
9 }
10
11 export class ForbiddenError extends HttpError {
12   constructor(msg: string = 'Forbidden') {
13     super(msg, 401, 'forbidden');
14   }
15 }
16
17 export class BadInputError extends HttpError {
18   constructor(msg: string = 'Bad Input') {
19     super(msg, 400, 'bad_input');
20   }
21 }
22
23 export class NotFoundError extends HttpError {
24   constructor(msg: string = 'Not Found') {
25     super(msg, 404, 'missing');
26   }
27 }