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

org.kiwiproject.jaxrs.exception.IllegalArgumentExceptionMapper Maven / Gradle / Ivy

Go to download

Kiwi is a utility library. We really like Google's Guava, and also use Apache Commons. But if they don't have something we need, and we think it is useful, this is where we put it.

There is a newer version: 4.5.2
Show newest version
package org.kiwiproject.jaxrs.exception;

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

/**
 * Map {@link IllegalArgumentException} to {@link Response}.
 * 

* The mapped response has status code 400 (Bad Request) and media type JSON. */ @Provider public class IllegalArgumentExceptionMapper implements ExceptionMapper { /** * Convert the given {@link IllegalArgumentException} to a 400 Bad Request response containing a JSON entity. * * @param exception the exception to convert * @return a response * @see JaxrsExceptionMapper#buildResponse(JaxrsException) */ @Override public Response toResponse(IllegalArgumentException exception) { return JaxrsExceptionMapper.buildResponse(new JaxrsBadRequestException(exception)); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy