More granular error responses

This commit is contained in:
Tom Moor
2018-02-19 23:31:18 -08:00
parent d73196594d
commit 5b6c908215
11 changed files with 67 additions and 68 deletions

View File

@ -1,6 +1,5 @@
// @flow
import Router from 'koa-router';
import httpErrors from 'http-errors';
import auth from './middlewares/authentication';
import pagination from './middlewares/pagination';
@ -55,11 +54,7 @@ router.post('apiKeys.delete', auth(), async ctx => {
const key = await ApiKey.findById(id);
authorize(user, 'delete', key);
try {
await key.destroy();
} catch (e) {
throw httpErrors.BadRequest('Error while deleting key');
}
await key.destroy();
ctx.body = {
success: true,