com.github.phillipkruger.apiee.providers.NonUniqueResultExceptionMapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of apiee-providers Show documentation
Show all versions of apiee-providers Show documentation
Some general Exception mappers
package com.github.phillipkruger.apiee.providers;
import javax.persistence.NonUniqueResultException;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
/**
* Translate Java non unique exceptions to HTTP response
* @author Phillip Kruger ([email protected])
*/
@Provider
public class NonUniqueResultExceptionMapper implements ExceptionMapper {
@Override
@Produces(MediaType.APPLICATION_JSON)
public Response toResponse(NonUniqueResultException nonUniqueResultException) {
return Response.status(Response.Status.CONFLICT).header(REASON,nonUniqueResultException.getMessage()).build();
}
private static final String REASON = "reason";
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy