Merge branch 'master' into dont-agree

This commit is contained in:
David Jay
2017-02-21 15:02:33 -05:00
committed by GitHub
52 changed files with 726 additions and 859 deletions
+17 -3
View File
@@ -1,3 +1,6 @@
const {Error: {ValidationError}} = require('mongoose');
const errors = require('../../errors');
/**
* Wraps up a promise to return an object with the resolution of the promise
* keyed at `key` or an error caught at `errors`.
@@ -9,9 +12,20 @@ const wrapResponse = (key) => (promise) => {
res[key] = value;
}
return res;
}).catch((err) => ({
errors: [err]
}));
}).catch((err) => {
if (err instanceof errors.APIError) {
return {
errors: [err]
};
} else if (err instanceof ValidationError) {
// TODO: wrap this with one of our internal errors.
throw err;
}
throw err;
});
};
const RootMutation = {