Tweaks error catching and messages.
[mkjsf-moved-to-github.git] / src / main / java / com / indexdata / mkjsf / pazpar2 / data / CommandError.java
index 9fbe0d0..7680ae5 100644 (file)
@@ -66,18 +66,19 @@ public class CommandError extends ResponseDataObject implements ErrorInterface {
    * Creates an XML string error message, embedded in an XML string document named by the command\r
    * This is the XML that ResponseParser will turn into a CommandError object. \r
    * @param commandName\r
-   * @param exceptionName\r
+   * @param exception\r
    * @param errorMessage\r
    * @return\r
    */\r
-  public static String createErrorXml (String commandName, String statusCode, String exceptionName, String errorMessage) {\r
+  public static String createErrorXml (String commandName, String statusCode, String exception, String errorMessage, String response) {\r
     StringBuilder errorXml = new StringBuilder("");\r
     errorXml.append("<" + commandName + ">"+nl);\r
     errorXml.append(" <applicationerror>"+nl);\r
     errorXml.append("  <commandname>" + commandName + "</commandname>"+nl);\r
     errorXml.append("  <statuscode>" + statusCode + "</statuscode>"+nl);\r
-    errorXml.append("  <exception>" + (exceptionName != null ? XmlUtils.escape(exceptionName) : "") + "</exception>"+nl);    \r
-    errorXml.append("  <errormessage>" + (errorMessage != null  ? XmlUtils.escape(errorMessage) : "") + "</errormessage>"+nl);    \r
+    errorXml.append("  <exception>" + (exception != null ? XmlUtils.escape(exception) : "") + "</exception>"+nl);    \r
+    errorXml.append("  <errormessage>" + (errorMessage != null  ? XmlUtils.escape(errorMessage) : "") + "</errormessage>"+nl);\r
+    errorXml.append("  <response>" + response + "</response>" + nl);\r
     errorXml.append(" </applicationerror>"+nl);\r
     errorXml.append("</" + commandName + ">"+nl);\r
     return errorXml.toString(); \r
@@ -90,18 +91,18 @@ public class CommandError extends ResponseDataObject implements ErrorInterface {
    * \r
    * \r
    * @param commandName The name of the command during which's execution the error was encountered\r
-   * @param exceptionName The (possibly loosely defined) name of the exception that was thrown\r
+   * @param exception The (possibly loosely defined) name of the exception that was thrown\r
    * @param pazpar2ErrorXml The error document as created by Pazpar2, or the Service Proxy or \r
    *                        by the Pazpar2 client itself. \r
    * @return\r
    */\r
-  public static String insertErrorXml (String commandName, String statusCode, String exceptionName, String pazpar2ErrorXml) {\r
+  public static String insertErrorXml (String commandName, String statusCode, String exception, String pazpar2ErrorXml) {\r
     StringBuilder errorXml = new StringBuilder("");\r
     errorXml.append("<" + commandName + ">"+nl);\r
     errorXml.append(" <applicationerror>"+nl);\r
     errorXml.append("  <commandname>" + commandName + "</commandname>"+nl);\r
     errorXml.append("  <statuscode>" + statusCode + "</statuscode>"+nl);\r
-    errorXml.append("  <exception>" + XmlUtils.escape(exceptionName) + "</exception>"+nl);    \r
+    errorXml.append("  <exception>" + XmlUtils.escape(exception) + "</exception>"+nl);    \r
     errorXml.append(xmlDeclaration.matcher(pazpar2ErrorXml).replaceAll("")+nl);    \r
     errorXml.append(" </applicationerror>"+nl);\r
     errorXml.append("</" + commandName + ">"+nl);\r