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

com.graphhopper.http.IllegalArgumentExceptionMapper Maven / Gradle / Ivy

There is a newer version: 10.0
Show newest version
package com.graphhopper.http;

import com.graphhopper.jackson.MultiException;
import com.graphhopper.util.Helper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

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(IllegalArgumentException e) {
        logger.info("bad request: " + (Helper.isEmpty(e.getMessage()) ? "unknown reason" : e.getMessage()));
        return Response.status(Response.Status.BAD_REQUEST)
                .entity(new MultiException(e))
                .build();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy