commit 5a414f9bcd631c538743ebccddb456b3e9eedb2f
parent d613766a104c25e5a7ce73cce8211ede1d27f36b
Author: Jan Dankert <devnull@localhost>
Date: Wed, 19 Dec 2018 15:41:12 +0100
new Exception for converting server-side exceptions.
Diffstat:
4 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/src/de/openrat/client/action/LoginAction.java b/src/de/openrat/client/action/LoginAction.java
@@ -6,6 +6,7 @@ import de.openrat.client.dto.User;
import de.openrat.client.util.CMSConnection;
import de.openrat.client.util.CMSException;
import de.openrat.client.util.CMSResponse;
+import de.openrat.client.util.CMSServerErrorException;
import de.openrat.client.util.HttpRequest.HttpMethod;
/**
@@ -52,7 +53,7 @@ public class LoginAction extends Action
}
catch (CMSException e)
{
- if ("LOGIN_FAILED".equals(e.getStatus()))
+ if (e instanceof CMSServerErrorException && ((CMSServerErrorException) e).getStatus().equals("LOGIN_FAILED"))
// wrong credentials - throw checked exception
throw new LoginException(e.getLocalizedMessage());
else
diff --git a/src/de/openrat/client/util/CMSRequest.java b/src/de/openrat/client/util/CMSRequest.java
@@ -23,6 +23,7 @@ package de.openrat.client.util;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringReader;
+import java.nio.file.FileSystems;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@@ -191,7 +192,19 @@ public class CMSRequest
String description = rootNode.getChild("description").getValue();
String reason = rootNode.getChild("reason").getValue();
- throw new CMSServerErrorException(error, status, description, reason);
+ ServerSideException cause = null;
+
+ // TODO only when trace available
+ cause = new ServerSideException();
+ final String file = "modules/cms-core/Dispatcher.class.php";
+ final String filename = FileSystems.getDefault().getPath(file).getFileName().toString();
+ final String method = "cms\\Dispatcher->commitDatabaseTransaction()";
+ final int line = 110;
+
+ StackTraceElement[] trace = new StackTraceElement[] { new StackTraceElement(file,method,filename,line) } ;
+
+ cause.setStackTrace( trace );
+ throw new CMSServerErrorException(error, status, description, reason, cause);
}
else
diff --git a/src/de/openrat/client/util/HttpClient.java b/src/de/openrat/client/util/HttpClient.java
@@ -321,7 +321,7 @@ public class HttpClient
}
catch (ConnectException e)
{
- throw new CMSException("cannot connect to " + socketAddress.toString(), "", "", e.getMessage(), e);
+ throw new CMSException("cannot connect to " + socketAddress.toString() + e.getMessage(), e);
}
if (connection.isKeepAlive())
diff --git a/src/de/openrat/client/util/ServerSideException.java b/src/de/openrat/client/util/ServerSideException.java
@@ -0,0 +1,8 @@
+package de.openrat.client.util;
+
+public class ServerSideException extends Exception {
+
+ public ServerSideException() {
+
+ }
+}