-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.js
More file actions
164 lines (150 loc) · 4.88 KB
/
Copy patherrors.js
File metadata and controls
164 lines (150 loc) · 4.88 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
var constaints = [
{
name: "segmento_name_empresaid_unique",
constraint: { field: "name", message: "El campo nombre ya se encuentra en la base de datos" }
}
];
module.exports = {
TIMEOUT_ERROR: class SERVER_ERROR extends Error {
constructor() {
super();
this.message = "Timeout";
this.label =
"La operacion duro mucho tiempo y no se pudo completar. Recarge la pagina para ver los cambios.";
this.solution = "RELOAD";
this.name = "TIMEOUT_ERROR";
this.type = "TIMEOUT_ERROR";
this.status = 508;
}
},
SERVER_ERROR: class SERVER_ERROR extends Error {
constructor(message) {
super();
this.message = message;
this.label = message;
this.solution = "RETRY";
this.name = "SERVER_ERROR";
this.type = "SERVER_ERROR";
this.status = 504;
}
},
DUPLICATE_FIELD: class DUPLICATE_FIELD extends Error {
constructor(sqlError, key) {
super();
this.message = sqlError.sqlMessage;
this.label = `El campo ${key} se esta utilizando y no se puede volver a usar.`;
this.solution = "INPUT";
this.name = "DUPLICATE_FIELD";
this.type = "DUPLICATE_FIELD";
this.status = 409;
}
},
DUPLICATE_ERROR: class DUPLICATE_ERROR extends Error {
constructor(sqlError, body) {
super();
var constraint = {
field: "*",
message: "Un campo se encuentra en la base de datos y no puede ser duplicado"
};
constaints.forEach(function(constraintLoop) {
if (sqlError.sqlMessage.indexOf(constraintLoop.name) > -1) constraint = constraintLoop.constraint;
});
this.message = sqlError.sqlMessage;
this.label = constraint.message;
this.solution = "INPUT";
this.duplicateKey = constraint.key;
this.name = "DUPLICATE_ERROR";
this.type = "DUPLICATE_ERROR";
this.status = 409;
}
},
VALIDATION_ERROR: class VALIDATION_ERROR extends Error {
constructor(message, errorArray, body) {
super();
this.message = JSON.stringify(body);
this.label = message;
this.errors = errorArray;
this.solution = "INPUT";
this.name = "VALIDATION_ERROR";
this.type = "VALIDATION_ERROR";
this.status = 400;
}
},
UPDATE_WITHOUT_RESULT: class UPDATE_WITHOUT_RESULT extends Error {
constructor(table, id, field, old, n) {
super();
this.message = `No se encontro el id ${id} en ${table} para hacer el update de ${JSON.stringify(
old
)} a ${JSON.stringify(n)}`;
this.label = `Ocurrio un error, no podemos encontrar este ${table}.`;
this.solution = "RELOAD";
this.name = "UPDATE_WITHOUT_RESULT";
this.type = "UPDATE_WITHOUT_RESULT";
this.status = 400;
}
},
ITEM_NOT_FOUND: class ITEM_NOT_FOUND extends Error {
constructor(table, id = "") {
super();
this.message = `No se encontro ${id} en ${table}`;
this.label = `Ocurrio un error, no podemos encontrar este ${table} ${id}.`;
this.solution = "RELOAD";
this.name = "ITEM_NOT_FOUND";
this.type = "ITEM_NOT_FOUND";
this.status = 404;
}
},
UPDATE_FIELD_CONFLICT: class UPDATE_FIELD_CONFLICT extends Error {
constructor(...args) {
super();
this.message = "El valor de este campo fue cambiado por otra persona, favor intente de nuevo.";
this.label = "El valor de este campo fue cambiado por otra persona, favor intente de nuevo.";
this.solution = "RELOAD";
this.name = "UPDATE_FIELD_CONFLICT";
this.type = "UPDATE_FIELD_CONFLICT";
this.status = 409;
}
},
UPDATE_LOCKED: class UPDATE_FIELD_CONFLICT extends Error {
constructor(message) {
super();
this.message = message;
this.label = message;
this.solution = "NONE";
this.name = "UPDATE_LOCKED";
this.type = "UPDATE_LOCKED";
this.status = 409;
}
},
INTEGRATION_ERROR: class INTEGRATION_ERROR extends Error {
constructor(...args) {
super(...args);
this.label =
"Ocurrio un en el sistema, no esta relacionado con el sistema. Comuniquese con Soporte Tecnico nivel Critico";
this.solution = "SUPPORT";
this.name = "INTEGRATION_ERROR";
this.type = "INTEGRATION_ERROR";
this.status = 500;
}
},
PERMISSION_ERROR: class PERMISSION_ERROR extends Error {
constructor(message) {
super();
this.label = message || "No tiene permiso para realizar esta acción";
this.solution = "ADMIN";
this.name = "PERMISSION_ERROR";
this.type = "PERMISSION_ERROR";
this.status = 403;
}
},
AUTH_ERROR: class PERMISSION_ERROR extends Error {
constructor(message) {
super();
this.label = message || "No esta registrado en el sistema, sera llevado a la pagina de Login.";
this.solution = "ADMIN";
this.name = "LOGIN_ERROR";
this.type = "LOGIN_ERROR";
this.status = 401;
}
}
};