From 53d183f7443b3813cc4f1878868b3c70dd3283ce Mon Sep 17 00:00:00 2001
From: Ludovic Claude <ludovic.claude54@gmail.com>
Date: Mon, 26 Jun 2017 11:55:08 +0200
Subject: [PATCH] Add null check

---
 .../mip/configuration/PortalErrorAttributes.java | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/main/java/eu/hbp/mip/configuration/PortalErrorAttributes.java b/src/main/java/eu/hbp/mip/configuration/PortalErrorAttributes.java
index 5c7f180be..da3096d94 100644
--- a/src/main/java/eu/hbp/mip/configuration/PortalErrorAttributes.java
+++ b/src/main/java/eu/hbp/mip/configuration/PortalErrorAttributes.java
@@ -19,13 +19,17 @@ public class PortalErrorAttributes extends DefaultErrorAttributes {
         Throwable throwable = getError(requestAttributes);
         LOGGER.warn("Reporting server error", throwable);
 
-        Throwable cause = throwable.getCause();
-        if (cause != null) {
-            Map<String, Object> causeErrorAttributes = new HashMap<>();
-            causeErrorAttributes.put("exception", cause.getClass().getName());
-            causeErrorAttributes.put("message", cause.getMessage());
-            errorAttributes.put("cause", causeErrorAttributes);
+        if (throwable != null) {
+
+            Throwable cause = throwable.getCause();
+            if (cause != null) {
+                Map<String, Object> causeErrorAttributes = new HashMap<>();
+                causeErrorAttributes.put("exception", cause.getClass().getName());
+                causeErrorAttributes.put("message", cause.getMessage());
+                errorAttributes.put("cause", causeErrorAttributes);
+            }
         }
+
         return errorAttributes;
     }
 }
-- 
GitLab