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

org.accidia.echo.resources.exceptions.IllegalArgumentExceptionMapper Maven / Gradle / Ivy

There is a newer version: 0.2.11
Show newest version
package org.accidia.echo.resources.exceptions;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

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

@Provider
public class IllegalArgumentExceptionMapper implements ExceptionMapper {
    private static final Logger logger = LoggerFactory.getLogger(IllegalArgumentExceptionMapper.class);

    @Override
    public Response toResponse(final IllegalArgumentException exception) {
        logger.debug("toResponse(exception)");
        logger.info("illegal argument exception: {}", exception);
        return Response
                .status(Response.Status.BAD_REQUEST)
                .entity(exception.getMessage())
                .type(MediaType.TEXT_PLAIN).build();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy