
com.bazaarvoice.ostrich.examples.dictionary.service.IllegalArgumentExceptionMapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dictionary-service Show documentation
Show all versions of dictionary-service Show documentation
Service implementation for the dictionary example
The newest version!
package com.bazaarvoice.ostrich.examples.dictionary.service;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
import java.util.Optional;
@Provider
public class IllegalArgumentExceptionMapper implements ExceptionMapper {
@Override
public Response toResponse(IllegalArgumentException e) {
return Response.status(Response.Status.BAD_REQUEST)
.header("X-BV-Exception", e.getClass().getName())
.entity(Optional.ofNullable(e.getMessage()).orElse("Invalid argument."))
.build();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy