1 export class HttpError extends Error {
4 constructor(msg: string, statusCode: number, errorCode: number) {
6 this.statusCode = statusCode;
7 this.errorCode = errorCode;
11 export class NotFoundError extends HttpError {
12 constructor(msg: string, errorCode: number) {
13 super(msg, 404, errorCode);
17 export class DuplicateContentError extends HttpError {
18 constructor(msg: string, errorCode: number) {
19 super(msg, 409, errorCode);
23 export class BadInputError extends HttpError {
24 constructor(msg: string, errorCode: number) {
25 super(msg, 400, errorCode);
29 export class InsufficientResourceError extends HttpError {
30 constructor(resource: string, expected: number, available: number) {
32 `Insufficent ${resource}. Expected: ${expected}, only ${available} available`,
34 ERROR_CODE.INSUFFICIENT_RESOURCE
39 export const ERROR_CODE = {
41 USER_ALREADY_EXISTS: 1001,
42 USER_PASSWORD_INCORRECT: 1002,
43 INVALID_USERNAME: 1003,
44 INVALID_PASSWORD: 1004,
45 INVALID_USER_TOKEN: 1005,
46 USING_ANOTHER_USERS_TOKEN: 1006,
48 INSUFFICIENT_RESOURCE: 3000,
49 INVALID_BUILDING: 4000,
51 DUPLICATE_CACHE_KEY: 900,