diff --git a/core/server/errors/index.js b/core/server/errors/index.js index 88de38a494..91aa13335f 100644 --- a/core/server/errors/index.js +++ b/core/server/errors/index.js @@ -193,6 +193,15 @@ errors = { return this.rejectError(error); } + // handle database errors + if (error.code && (error.errno || error.detail)) { + error.db_error_code = error.code; + error.type = 'DatabaseError'; + error.code = 500; + + return this.rejectError(error); + } + return this.rejectError(new this.InternalServerError(error)); },