We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ac57ff1 commit b62a64aCopy full SHA for b62a64a
src/main/kotlin/org/exploit/keeper/component/exception/BadRequestExceptionMapper.kt
@@ -0,0 +1,17 @@
1
+package org.exploit.keeper.component.exception
2
+
3
+import jakarta.ws.rs.BadRequestException
4
+import jakarta.ws.rs.core.MediaType
5
+import jakarta.ws.rs.core.Response
6
+import jakarta.ws.rs.ext.ExceptionMapper
7
+import jakarta.ws.rs.ext.Provider
8
9
+@Provider
10
+class BadRequestExceptionMapper : ExceptionMapper<BadRequestException> {
11
+ override fun toResponse(exception: BadRequestException): Response {
12
+ return Response.status(Response.Status.BAD_REQUEST)
13
+ .entity(mapOf("error" to (exception.message ?: "Bad request")))
14
+ .type(MediaType.APPLICATION_JSON)
15
+ .build()
16
+ }
17
+}
0 commit comments