mirror of
https://github.com/wassname/talk.git
synced 2026-07-13 17:45:56 +08:00
Merge branch 'master' into dont-agree
This commit is contained in:
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user