File size: 502 Bytes
7324743
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// errors.js
export class ApiError extends Error {
    constructor(message, status = 500, code = 'INTERNAL_SERVER_ERROR') {
        super(message);
        this.status = status;
        this.code = code;
    }
}

export class ValidationError extends ApiError {
    constructor(message) {
        super(message, 400, 'VALIDATION_ERROR');
    }
}

export class AuthenticationError extends ApiError {
    constructor(message = 'Unauthorized') {
        super(message, 401, 'AUTHENTICATION_ERROR');
    }
}