Skip to content
This repository has been archived by the owner on Dec 2, 2018. It is now read-only.

Commit

Permalink
Format database-related error responses
Browse files Browse the repository at this point in the history
Closes TryGhost#4735
- Shows error message on client instead of "[object Object]".
- Server log shows error message instead of uknown error.
  • Loading branch information
jaswilli committed Jan 21, 2015
1 parent 8454a1c commit 786ec6b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions core/server/errors/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
},

Expand Down

0 comments on commit 786ec6b

Please sign in to comment.