From 9f0eb1a26745e51dc39184882d542583ba4ab7e5 Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Wed, 14 Mar 2007 20:32:37 +0000
Subject: [PATCH] Update the LDAP client tools so that they provide error messages in a more readable format.  They can now generate up to four lines of output in the following order:

---
 opends/src/server/org/opends/server/tools/LDAPConnection.java |   30 +++++++++++++++++++-----------
 1 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/opends/src/server/org/opends/server/tools/LDAPConnection.java b/opends/src/server/org/opends/server/tools/LDAPConnection.java
index 738f174..a7b5575 100644
--- a/opends/src/server/org/opends/server/tools/LDAPConnection.java
+++ b/opends/src/server/org/opends/server/tools/LDAPConnection.java
@@ -44,6 +44,7 @@
 import org.opends.server.protocols.ldap.ExtendedRequestProtocolOp;
 import org.opends.server.protocols.ldap.ExtendedResponseProtocolOp;
 import org.opends.server.protocols.ldap.LDAPControl;
+import org.opends.server.protocols.ldap.LDAPException;
 import org.opends.server.protocols.ldap.LDAPMessage;
 import org.opends.server.protocols.ldap.UnbindRequestProtocolOp;
 import org.opends.server.types.Control;
@@ -166,12 +167,14 @@
       {
         int msgID = MSGID_RESULT_CLIENT_SIDE_CONNECT_ERROR;
         String msg = getMessage(msgID);
-        throw new LDAPConnectionException(msg, CLIENT_SIDE_CONNECT_ERROR, uhe);
+        throw new LDAPConnectionException(msg, CLIENT_SIDE_CONNECT_ERROR, null,
+                                          uhe);
       } catch(ConnectException ce)
       {
         int msgID = MSGID_RESULT_CLIENT_SIDE_CONNECT_ERROR;
         String msg = getMessage(msgID);
-        throw new LDAPConnectionException(msg, CLIENT_SIDE_CONNECT_ERROR, ce);
+        throw new LDAPConnectionException(msg, CLIENT_SIDE_CONNECT_ERROR, null,
+                                          ce);
       } catch(Exception ex)
       {
         if (debugEnabled())
@@ -205,12 +208,9 @@
       resultCode = res.getResultCode();
       if(resultCode != SUCCESS)
       {
-        String message = res.getErrorMessage();
-        if(message == null)
-        {
-          message = "Response code:" + resultCode;
-        }
-        throw new LDAPConnectionException(message);
+        throw new LDAPConnectionException(res.getErrorMessage(), resultCode,
+                                          res.getErrorMessage(),
+                                          res.getMatchedDN(), null);
       }
     }
     SSLConnectionFactory sslConnectionFactory =
@@ -238,12 +238,14 @@
     {
       int msgID = MSGID_RESULT_CLIENT_SIDE_CONNECT_ERROR;
       String msg = getMessage(msgID);
-      throw new LDAPConnectionException(msg, CLIENT_SIDE_CONNECT_ERROR, uhe);
+      throw new LDAPConnectionException(msg, CLIENT_SIDE_CONNECT_ERROR, null,
+                                        uhe);
     } catch(ConnectException ce)
     {
       int msgID = MSGID_RESULT_CLIENT_SIDE_CONNECT_ERROR;
       String msg = getMessage(msgID);
-      throw new LDAPConnectionException(msg, CLIENT_SIDE_CONNECT_ERROR, ce);
+      throw new LDAPConnectionException(msg, CLIENT_SIDE_CONNECT_ERROR, null,
+                                        ce);
     } catch(Exception ex2)
     {
       if (debugEnabled())
@@ -406,7 +408,13 @@
       {
         debugCaught(DebugLogLevel.ERROR, ce);
       }
-      throw new LDAPConnectionException(ce.getMessage(), ce.getExitCode(), ce);
+      throw new LDAPConnectionException(ce.getMessage(), ce.getExitCode(),
+                                        null, ce);
+    } catch (LDAPException le)
+    {
+      throw new LDAPConnectionException(le.getMessage(), le.getResultCode(),
+                                        le.getErrorMessage(), le.getMatchedDN(),
+                                        le.getCause());
     } catch(Exception ex)
     {
       if (debugEnabled())

--
Gitblit v1.10.0