net.leanix.dropkit.BusinessLogicExceptionMapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of leanix-dropkit Show documentation
Show all versions of leanix-dropkit Show documentation
Base functionality for leanIX dropwizard-based services
package net.leanix.dropkit;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
import net.leanix.dropkit.responses.BasicResponse;
/**
*
* @link http://stackoverflow.com/questions/24573028/dropwizard-custom-exception-for-invalidentityexception
*/
@Provider
public class BusinessLogicExceptionMapper implements ExceptionMapper {
/**
* Builds a response. Remark: Should not automatically log its results, otherwise any exception ends up in log file,
* although business logic exceptions should not end up here
*
* @param ex
* @return
*/
@Override
public Response toResponse(BusinessLogicException ex) {
return Response.status(ex.getStatus())
.entity(new BasicResponse(ex))
.type("text/json")
.build();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy