Skip to content

Commit

Permalink
Merge pull request #128 from protokol/chore/errors
Browse files Browse the repository at this point in the history
refactor: Improve validation error handling
  • Loading branch information
artuan authored Dec 12, 2024
2 parents 4933272 + 13f5b87 commit b96230d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion apps/backend/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ async function bootstrap() {
const constraints = firstError.constraints;

if (!constraints || Object.keys(constraints).length === 0) {
throw new Error('Validation failed: No constraints provided.');
return new HttpException(
createError(
'INVALID_REQUEST',
'Validation failed: Invalid or missing constraints'
),
HttpStatus.BAD_REQUEST
);
}

return new HttpException(
Expand Down

0 comments on commit b96230d

Please sign in to comment.