Skip to content

Commit

Permalink
Merge pull request #129 from dwasinge/response-mapping
Browse files Browse the repository at this point in the history
Response Mapper for WebApplicationExceptions
  • Loading branch information
mcanoy authored Mar 10, 2021
2 parents fb82946 + a7e7f67 commit 2365c0b
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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<WebApplicationException> {

@Override
public Response toResponse(WebApplicationException exception) {

Map<String, String> map = new HashMap<>();
map.put("message", exception.getMessage());

return Response.status(exception.getResponse().getStatus()).entity(map).build();

}

}

0 comments on commit 2365c0b

Please sign in to comment.