diff --git a/src/main/java/com/redhat/labs/lodestar/exception/mapper/GitApiExceptionHandler.java b/src/main/java/com/redhat/labs/lodestar/exception/mapper/GitApiExceptionHandler.java new file mode 100644 index 0000000..c4b877d --- /dev/null +++ b/src/main/java/com/redhat/labs/lodestar/exception/mapper/GitApiExceptionHandler.java @@ -0,0 +1,24 @@ +package com.redhat.labs.lodestar.exception.mapper; + +import java.util.HashMap; +import java.util.Map; + +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.Response; +import javax.ws.rs.ext.ExceptionMapper; +import javax.ws.rs.ext.Provider; + +@Provider +public class GitApiExceptionHandler implements ExceptionMapper { + + @Override + public Response toResponse(WebApplicationException exception) { + + Map map = new HashMap<>(); + map.put("message", exception.getMessage()); + + return Response.status(exception.getResponse().getStatus()).entity(map).build(); + + } + +}