-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.js
More file actions
83 lines (74 loc) · 2.12 KB
/
errors.js
File metadata and controls
83 lines (74 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
class PokemonBadRequest extends Error {
constructor(message) {
super(message);
this.name = 'PokemonBadRequest';
if (!message) this.message = "Error - Bad request: check the API doc";
this.pokeErrCode = 400;
}
}
class PokemonNotFoundError extends Error {
constructor(message) {
super(message);
this.name = 'PokemonNotFoundError';
this.message = "Error - Pokemon was not found: check your request";
this.pokeErrCode = 400;
}
}
class PokemonDbError extends Error {
constructor(message) {
super(message);
this.name = 'PokemonDbError';
this.message = "Error - DB error: Contact API owners for more info.";
this.pokeErrCode = 500;
}
}
class PokemonDuplicateError extends PokemonBadRequest {
constructor(message) {
super(message);
this.name = 'PokemonDuplicateError';
this.message = "Error - PokemonDuplicateError: The Pokemons has already been inserted.";
this.pokeErrCode = 400;
}
}
class PokemonBadRequestMissingID extends PokemonBadRequest {
constructor(message) {
super(message);
this.name = 'PokemonBadRequestMissingID';
this.message = "Error - Bad request: check the API doc";
this.pokeErrCode = 400;
}
}
class PokemonBadRequestMissingAfter extends PokemonBadRequest {
constructor(message) {
super(message);
this.name = 'PokemonBadRequestMissingAfter';
this.message = "Error - Bad request: check the API doc";
this.pokeErrCode = 400;
}
}
class PokemonNoSuchRouteError extends PokemonBadRequest {
constructor(message) {
super(message);
this.name = 'PokemonNoSuchRouteError';
this.message = "Error - Improper Route: check the API doc";
this.pokeErrCode = 404;
}
}
class PokemonAuthError extends PokemonBadRequest {
constructor(message) {
super(message);
this.name = 'PokemonAuthError';
this.message = `Poke API Error - Authentication Error: ${message}`;
this.pokeErrCode = 401;
}
}
module.exports = {
PokemonBadRequest,
PokemonBadRequestMissingID,
PokemonBadRequestMissingAfter,
PokemonDbError,
PokemonNotFoundError,
PokemonDuplicateError,
PokemonNoSuchRouteError,
PokemonAuthError
};