Skip to content

Conversation

@mechite
Copy link
Contributor

@mechite mechite commented Aug 17, 2025

Adds a simple extension to HttpResponseException.
Unlike Javalin, which has e.g. UnauthorizedResponse, we do not have such exceptions for every HTTP error code response.
Furthermore, for the ones we do have them for, e.g. Javalin's BadRequestResponse we have BadRequestException, you still need to provide a message.

With this PR, you can now run
throw new HttpResponseException(UNAUTHORIZED_401) which will use the message Unauthorized like Javalin does
throw new HttpResponseException(UNAUTHORIZED_401, "Unauthorized [forgot to mash the potatoes!]) for a custom message.

@SentryMan SentryMan enabled auto-merge (squash) August 17, 2025 19:31
@SentryMan SentryMan merged commit c717910 into avaje:master Aug 17, 2025
6 checks passed
@SentryMan SentryMan added this to the 3.3 milestone Aug 22, 2025
@SentryMan SentryMan added the enhancement New feature or request label Aug 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants