Skip to content

Commit

Permalink
fix(adm): throw HTTPError for user errors
Browse files Browse the repository at this point in the history
  • Loading branch information
MrOrz committed Nov 18, 2024
1 parent fd28e66 commit b52985f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/adm/handlers/moderation/blockUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*
* Please announce that the user will be blocked openly with a URL first.
*/
import { HTTPError } from 'fets';

import client from 'util/client';
import getAllDocs from 'util/getAllDocs';
Expand Down Expand Up @@ -47,7 +48,7 @@ async function writeBlockedReasonToUser(userId: string, blockedReason: string) {
'message' in e &&
e.message === 'document_missing_exception'
) {
throw new Error(`User with ID=${userId} does not exist`);
throw new HTTPError(400, `User with ID=${userId} does not exist`);
}

throw e;
Expand Down
4 changes: 3 additions & 1 deletion src/adm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ const router = createRouter({
{ additionalProperties: false }
),
},
responses: { 200: Type.Object({ success: Type.Boolean() }) },
responses: {
200: Type.Object({ success: Type.Boolean() }),
},
},
handler: async (request) =>
Response.json(await blockUser(await request.json())),
Expand Down

0 comments on commit b52985f

Please sign in to comment.