Fix a bug in error parsing #21

Merged
joeybaker merged 3 commits from better-error into master 2016-09-05 19:25:14 +00:00
Showing only changes of commit bab2e90cbb - Show all commits

View File

@ -13,7 +13,15 @@ export default (target, key, descriptor) => {
// pg error codes https://www.postgresql.org/docs/9.5/static/errcodes-appendix.html // pg error codes https://www.postgresql.org/docs/9.5/static/errcodes-appendix.html
if (code && (code.startsWith('22') || code.startsWith('23'))) { if (code && (code.startsWith('22') || code.startsWith('23'))) {
const error = Boom.wrap(e, 406); error = Boom.wrap(e, 406);
} else if (code && (code.startsWith('42'))) {
error = Boom.wrap(e, 422);
// TODO: we could get better at parse postgres error codes
} else {
// use a 502 error code since the issue is upstream with postgres, not
// this server
error = Boom.wrap(e, 502);
}
// detail tends to be more specific information. So, if we have it, use. // detail tends to be more specific information. So, if we have it, use.
if (detail) { if (detail) {