Qyanger 6 mesi fa
parent
commit
81452a11d5

+ 8 - 1
src/main/java/com/demo/seecanalysisbackend/exception/GlobalExceptionHandler.java

@@ -58,7 +58,14 @@ public class GlobalExceptionHandler {
         response.put("timestamp", LocalDateTime.now());
         response.put("status", HttpStatus.INTERNAL_SERVER_ERROR.value());
         response.put("error", "Internal Server Error");
-        response.put("message", "An unexpected error occurred");
+        response.put("message", ex.getMessage() != null ? ex.getMessage() : "An unexpected error occurred");
+        response.put("exception", ex.getClass().getName());
+        Throwable rootCause = ex;
+        while (rootCause.getCause() != null) {
+            rootCause = rootCause.getCause();
+        }
+        response.put("rootCause", rootCause.getClass().getName());
+        response.put("rootCauseMessage", rootCause.getMessage());
         
         return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response);
     }