| .. | .. |
|---|
| 10 | 10 | import javax.ws.rs.ext.ExceptionMapper; |
|---|
| 11 | 11 | import javax.ws.rs.ext.Provider; |
|---|
| 12 | 12 | |
|---|
| 13 | +import net.curisit.securis.services.exception.SeCurisServiceException; |
|---|
| 14 | + |
|---|
| 13 | 15 | import org.slf4j.Logger; |
|---|
| 14 | 16 | import org.slf4j.LoggerFactory; |
|---|
| 15 | 17 | |
|---|
| .. | .. |
|---|
| 37 | 39 | return Response.status(Status.UNAUTHORIZED).header(ERROR_MESSAGE_HEADER, "Unathorized access to the application").type(MediaType.APPLICATION_JSON).build(); |
|---|
| 38 | 40 | } |
|---|
| 39 | 41 | |
|---|
| 42 | + if (e instanceof SeCurisServiceException) { |
|---|
| 43 | + log.warn("SeCurisServiceException accessing to {}, user: {}", request.getPathInfo(), bsc.getUserPrincipal()); |
|---|
| 44 | + return Response.status(Status.fromStatusCode(((SeCurisServiceException) e).getStatus())).header(ERROR_MESSAGE_HEADER, e.getMessage()).type(MediaType.APPLICATION_JSON).build(); |
|---|
| 45 | + } |
|---|
| 46 | + |
|---|
| 40 | 47 | log.error("Unexpected error accesing to '{}' by user: {}", request.getPathInfo(), bsc.getUserPrincipal()); |
|---|
| 41 | 48 | log.error("Request sent from {}, with User-Agent: {}", request.getRemoteHost(), request.getHeader("User-Agent")); |
|---|
| 42 | 49 | log.error("Request url: " + request.getRequestURL(), e); |
|---|