From bab2e90cbbf77e01093468a76d54f0dc5d31808f Mon Sep 17 00:00:00 2001 From: Joey Baker Date: Sun, 4 Sep 2016 17:27:07 -0700 Subject: [PATCH] Feat (error) parse PG 42* errors --- src/error.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/error.js b/src/error.js index 54fdc7e..3bb7384 100644 --- a/src/error.js +++ b/src/error.js @@ -13,7 +13,15 @@ export default (target, key, descriptor) => { // pg error codes https://www.postgresql.org/docs/9.5/static/errcodes-appendix.html 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. if (detail) {