Improve error messages to prevent leakage

Change-Id: I1df18ddcb352c74f7cf782b3c870a8cfcd14ecd3
diff --git a/Changes b/Changes
index 920712c..33447f4 100644
--- a/Changes
+++ b/Changes
@@ -1,8 +1,9 @@
-0.2.4 2021-04-28
+0.2.4 2021-05-07
     - Fix temporary session-riding capabilities.
     - Introduced central tinylog.
     - Fix nullpointer in RTF export.
     - Fix nullpointer in CSV export.
+    - Improve error messages to avoid information leakage.
 
 0.2.3 2021-03-24
     - Added trail info to RTF export.
\ No newline at end of file
diff --git a/src/main/java/de/ids_mannheim/korap/plkexport/Service.java b/src/main/java/de/ids_mannheim/korap/plkexport/Service.java
index e69eb3c..cb0d7ae 100644
--- a/src/main/java/de/ids_mannheim/korap/plkexport/Service.java
+++ b/src/main/java/de/ids_mannheim/korap/plkexport/Service.java
@@ -272,10 +272,15 @@
 
         catch (Exception e) {
             Logger.error(e);
+            String err = e.getMessage();
+            if (err == null) {
+                err = "Unable to initialize export";
+            };
+
             throw new WebApplicationException(
                 responseForm(
                     Status.INTERNAL_SERVER_ERROR,
-                    e.getMessage()
+                    err
                     )
                 );
         };
@@ -303,10 +308,15 @@
 
             catch (Exception e) {
                 Logger.error(e);
+                String err = e.getMessage();
+                if (err == null) {
+                    err = "Unable to finish export";
+                };
+                
                 throw new WebApplicationException(
                     responseForm(
                         Status.INTERNAL_SERVER_ERROR,
-                        e.getMessage()
+                        err
                         )
                     );
             };
@@ -344,10 +354,14 @@
 
         catch (Exception e) {
             Logger.error(e);
+            String err = e.getMessage();
+            if (err == null) {
+                err = "Unable to iterate through results";
+            };
             throw new WebApplicationException(
                 responseForm(
                     Status.INTERNAL_SERVER_ERROR,
-                    e.getMessage()
+                    err
                     )
                 );
         };