All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.codehaus.jackson.jaxrs.JsonMappingExceptionMapper Maven / Gradle / Ivy

Go to download

Jax-RS provider for JSON content type, based on Jackson JSON processor's data binding functionality.

There is a newer version: 1.9.13
Show newest version
package org.codehaus.jackson.jaxrs;

import org.codehaus.jackson.map.JsonMappingException;

import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;

/**
 * Implementation if {@link ExceptionMapper} to send down a "400 Bad Request"
 * response in the event that unmappable JSON is received.
 */
@Provider
public class JsonMappingExceptionMapper implements ExceptionMapper {
    // only compiles on 1.6:
    //@Override
    public Response toResponse(JsonMappingException exception) {
        return Response.status(Response.Status.BAD_REQUEST).entity(exception.getMessage()).type("text/plain").build();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy