com.fasterxml.jackson.jakarta.rs.base.JsonParseExceptionMapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jackson-jakarta-rs-base Show documentation
Show all versions of jackson-jakarta-rs-base Show documentation
Pile of code that is shared by all Jackson-based Jakarta-RS
providers.
package com.fasterxml.jackson.jakarta.rs.base;
import com.fasterxml.jackson.core.JsonParseException;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.ext.ExceptionMapper;
/**
* Implementation of {@link ExceptionMapper} to send down a "400 Bad Request"
* in the event unparsable JSON is received.
*/
public class JsonParseExceptionMapper implements ExceptionMapper {
@Override
public Response toResponse(JsonParseException exception) {
return Response.status(Response.Status.BAD_REQUEST).entity(exception.getMessage()).type("text/plain").build();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy