Merge pull request #17 from Getable/fix-babel-polyfill

Fixes for babel-polyfill
This commit is contained in:
Mahdi Dibaiee 2016-08-30 09:48:20 +04:30 committed by GitHub
commit 517f2b8157
3 changed files with 4 additions and 23 deletions

View File

@ -38,5 +38,8 @@
"boom": "^3.2.2", "boom": "^3.2.2",
"joi": "7.2.1", "joi": "7.2.1",
"lodash": "4.0.0" "lodash": "4.0.0"
},
"optionalDependencies": {
"babel-polyfill": "^6.13.0"
} }
} }

View File

@ -1,8 +1,4 @@
<<<<<<< b18479e02e3d47da4e40369a8132e07125eb96a3
import Boom from 'boom'; import Boom from 'boom';
=======
import { wrap } from 'boom';
>>>>>>> whatever
export default (target, key, descriptor) => { export default (target, key, descriptor) => {
const fn = descriptor.value; const fn = descriptor.value;
@ -11,7 +7,6 @@ export default (target, key, descriptor) => {
try { try {
await fn(request, reply); await fn(request, reply);
} catch (e) { } catch (e) {
<<<<<<< b18479e02e3d47da4e40369a8132e07125eb96a3
if (e.original) { if (e.original) {
const { code, detail } = e.original; const { code, detail } = e.original;
@ -50,23 +45,6 @@ export default (target, key, descriptor) => {
reply(err); reply(err);
} else { } else {
reply(e); reply(e);
=======
const { code, detail } = e.original;
// pg error codes https://www.postgresql.org/docs/9.5/static/errcodes-appendix.html
if (code && (code.startsWith('22') || code.startsWith('23'))) {
const error = wrap(e, 406);
// detail tends to be more specific information. So, if we have it, use.
if (detail) {
error.message += `: ${detail}`;
error.reformat();
}
reply(error);
} else {
reply(wrap(e));
>>>>>>> whatever
} }
} }
}; };

View File

@ -1,5 +1,5 @@
if (!global._babelPolyfill) { if (!global._babelPolyfill) {
require('babel/polyfill'); require('babel-polyfill');
} }
import crud, { associations } from './crud'; import crud, { associations } from './crud';