package fr.insee.pogues.webservice.rest;

import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.ext.Provider;

/**
 * Created by acordier on 04/07/17.
 */
@Provider
public class GenericExceptionMapper implements ExceptionMapper<Throwable> {

    private final Status STATUS = Status.INTERNAL_SERVER_ERROR;

    public Response toResponse(Throwable error){
        RestMessage message = new RestMessage(
                STATUS.getStatusCode(),
                "An unexpected error occured", error.getMessage());
        return Response.status(STATUS)
                .entity(message)
                .type(MediaType.APPLICATION_JSON)
                .build();
    }
}

@@ -35,16 +35,87 @@
 .rest;%0A%0A
+import org.apache.log4j.Logger;%0A%0Aimport javax.ws.rs.NotFoundException;%0A
 import j
@@ -141,16 +141,16 @@
 iaType;%0A
-
 import j
@@ -437,14 +437,8 @@
 ate 
-final 
 Stat
@@ -480,16 +480,93 @@
 ERROR;%0A%0A
+    private Logger logger = Logger.getLogger(GenericExceptionMapper.class);%0A%0A
     publ
@@ -693,16 +693,16 @@
 Code(),%0A
-
         
@@ -761,16 +761,233 @@
 age());%0A
+        if(error instanceof NotFoundException) %7B%0A            STATUS = Status.NOT_FOUND;%0A            message.setMessage(%22Not Found%22);%0A            message.setDetails(%22No JAX-RS resource found for this path%22);%0A        %7D%0A
         

Make exception mapper more accurate on jax-rs internal error