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,7 +1,6 @@
// @flow
import Router from 'koa-router';
import httpErrors from 'http-errors';
import { ValidationError } from '../errors';
import { Team, User } from '../models';
import auth from './middlewares/authentication';
@ -61,7 +60,7 @@ router.post('team.removeAdmin', auth(), async ctx => {
try {
await team.removeAdmin(user);
} catch (err) {
throw httpErrors.BadRequest(err.message);
throw new ValidationError(err.message);
}
ctx.body = {