0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00

Format database-related error responses

Closes #4735
- Shows error message on client instead of "[object Object]".
- Server log shows error message instead of uknown error.
This commit is contained in:
Jason Williams 2015-01-21 18:01:19 +00:00
parent 8454a1c0bb
commit 786ec6be28

View file

@ -193,6 +193,15 @@ errors = {
return this.rejectError(error); 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)); return this.rejectError(new this.InternalServerError(error));
}, },