org.kiwiproject.jaxrs.exception.IllegalStateExceptionMapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kiwi Show documentation
Show all versions of kiwi Show documentation
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.
package org.kiwiproject.jaxrs.exception;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.ext.ExceptionMapper;
import jakarta.ws.rs.ext.Provider;
/**
* Map {@link IllegalStateException} to {@link Response}.
*
* The mapped response has status code 500 (Internal Server Error) and media type JSON.
*/
@Provider
public class IllegalStateExceptionMapper implements ExceptionMapper {
/**
* Convert the given {@link IllegalStateException} to a 500 Internal Server Error response containing a JSON entity.
*
* @param exception the exception to convert
* @return a response
* @see JaxrsExceptionMapper#buildResponse(JaxrsException)
*/
@Override
public Response toResponse(IllegalStateException exception) {
return JaxrsExceptionMapper.buildResponse(new JaxrsException(exception, 500));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy