getName refactor
This commit is contained in:
parent
2bfa00ab57
commit
e611d21029
@ -1,4 +1,5 @@
|
||||
var PgErrorHandler = require('../postgresql/error_handler');
|
||||
var pgErrorCodes = require('../postgresql/error_codes');
|
||||
|
||||
module.exports = function errorMiddleware() {
|
||||
return function error(err, req, res, next) {
|
||||
@ -117,6 +118,6 @@ function createPgError(err) {
|
||||
err.detail,
|
||||
err.hint,
|
||||
err.http_status,
|
||||
PgErrorHandler.getName(err)
|
||||
pgErrorCodes.codeToCondition[err.code] || err.name
|
||||
);
|
||||
}
|
||||
|
@ -1,5 +1,3 @@
|
||||
var pgErrorCodes = require('./error_codes');
|
||||
|
||||
class ErrorHandler extends Error {
|
||||
constructor(message, context, detail, hint, http_status = 400, name = null) {
|
||||
super(message);
|
||||
@ -22,10 +20,6 @@ class ErrorHandler extends Error {
|
||||
hint: this.hint
|
||||
};
|
||||
}
|
||||
|
||||
static getName (err) {
|
||||
return pgErrorCodes.codeToCondition[err.code] || err.name;
|
||||
}
|
||||
|
||||
getHttpStatus (http_status) {
|
||||
if (this.message.includes('permission denied')) {
|
||||
|
Loading…
Reference in New Issue
Block a user