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

cd.connect.jersey.common.JerseyExceptionMapper Maven / Gradle / Ivy

The newest version!
package cd.connect.jersey.common;

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

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

@Provider
public class JerseyExceptionMapper implements ExceptionMapper {
	private static final Logger log = LoggerFactory.getLogger(JerseyExceptionMapper.class);
	@Override
	public Response toResponse(Exception exception) {
		if (exception instanceof WebApplicationException) {
			return ((WebApplicationException)exception).getResponse();
		}
		
		log.error("Failed jersey request", exception);
		return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy