This is an automated email from the ASF dual-hosted git repository.

dgriffon pushed a commit to branch unomi-1.5.x
in repository https://gitbox.apache.org/repos/asf/unomi.git


The following commit(s) were added to refs/heads/unomi-1.5.x by this push:
     new 781db03  UNOMI-488 : log error in RuntimeExceptionMapper (#311)
781db03 is described below

commit 781db03d364ca68f2daf1d988e8444e6a468bd5a
Author: David Griffon <[email protected]>
AuthorDate: Thu Jun 10 17:06:38 2021 +0200

    UNOMI-488 : log error in RuntimeExceptionMapper (#311)
---
 .../apache/unomi/rest/exception/RuntimeExceptionMapper.java | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git 
a/rest/src/main/java/org/apache/unomi/rest/exception/RuntimeExceptionMapper.java
 
b/rest/src/main/java/org/apache/unomi/rest/exception/RuntimeExceptionMapper.java
index 9bdce40..00ee3dc 100644
--- 
a/rest/src/main/java/org/apache/unomi/rest/exception/RuntimeExceptionMapper.java
+++ 
b/rest/src/main/java/org/apache/unomi/rest/exception/RuntimeExceptionMapper.java
@@ -16,7 +16,10 @@
  */
 package org.apache.unomi.rest.exception;
 
+import org.apache.commons.lang.ArrayUtils;
 import org.osgi.service.component.annotations.Component;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
@@ -28,11 +31,19 @@ import java.util.HashMap;
 @Provider
 @Component(service=ExceptionMapper.class)
 public class RuntimeExceptionMapper implements 
ExceptionMapper<RuntimeException> {
+    private static final Logger logger = 
LoggerFactory.getLogger(RuntimeExceptionMapper.class.getName());
 
     @Override
     public Response toResponse(RuntimeException exception) {
         HashMap<String, Object> body = new HashMap<>();
         body.put("errorMessage", "internalServerError");
+        logger.error(
+                "Internal server error {}: {} in {} (Set 
RuntimeExceptionMapper in debug to get the full stacktrace)",
+                exception.getMessage(),
+                exception,
+                ArrayUtils.isEmpty(exception.getStackTrace()) ? "Stack not 
available" : exception.getStackTrace()[0]
+        );
+        logger.debug("{}", exception.getMessage(), exception);
         return 
Response.status(Response.Status.INTERNAL_SERVER_ERROR).header("Content-Type", 
MediaType.APPLICATION_JSON).entity(body).build();
     }
-}
\ No newline at end of file
+}

Reply via email to