ONOS-3369: log an exception on REST server errors

Change-Id: I407ed7576ff79b5781d2a688c78367266643aaea
diff --git a/web/api/src/main/java/org/onosproject/rest/exceptions/AbstractMapper.java b/web/api/src/main/java/org/onosproject/rest/exceptions/AbstractMapper.java
index f49202d..0d9d94d 100644
--- a/web/api/src/main/java/org/onosproject/rest/exceptions/AbstractMapper.java
+++ b/web/api/src/main/java/org/onosproject/rest/exceptions/AbstractMapper.java
@@ -29,6 +29,11 @@
 public abstract class AbstractMapper<E extends Throwable> implements ExceptionMapper<E> {
 
     /**
+     * Holds the current exception for use in subclasses.
+     */
+    protected Throwable error;
+
+    /**
      * Returns the response status to be given when the exception occurs.
      *
      * @return response status
@@ -37,6 +42,7 @@
 
     @Override
     public Response toResponse(E exception) {
+        error = exception;
         return response(responseStatus(), exception).build();
     }
 
@@ -50,6 +56,7 @@
      */
     protected Response.ResponseBuilder response(Response.Status status,
                                                 Throwable exception) {
+        error = exception;
         ObjectMapper mapper = new ObjectMapper();
         String message = messageFrom(exception);
         ObjectNode result = mapper.createObjectNode()
diff --git a/web/api/src/main/java/org/onosproject/rest/exceptions/ServerErrorMapper.java b/web/api/src/main/java/org/onosproject/rest/exceptions/ServerErrorMapper.java
index 5a9050d..778750e 100644
--- a/web/api/src/main/java/org/onosproject/rest/exceptions/ServerErrorMapper.java
+++ b/web/api/src/main/java/org/onosproject/rest/exceptions/ServerErrorMapper.java
@@ -18,13 +18,19 @@
 import javax.ws.rs.core.Response;
 import javax.ws.rs.ext.Provider;
 
+import org.slf4j.Logger;
+
+import static org.slf4j.LoggerFactory.getLogger;
+
 /**
  * Mapper for service not found exceptions to the INTERNAL_SERVER_ERROR response code.
  */
 @Provider
 public class ServerErrorMapper extends AbstractMapper<RuntimeException> {
+    private static final Logger log = getLogger(ServerErrorMapper.class);
     @Override
     protected Response.Status responseStatus() {
+        log.warn("Unhandled REST exception", error);
         return Response.Status.INTERNAL_SERVER_ERROR;
     }
 }