From e54deb8b792b9b16880f7e3c3783aa0c620d1721 Mon Sep 17 00:00:00 2001
From: Fabio Pistolesi <fabio.pistolesi@forgerock.com>
Date: Thu, 07 Jul 2016 08:33:54 +0000
Subject: [PATCH] Display more information about errors while reading server information

---
 opendj-config/src/main/resources/com/forgerock/opendj/ldap/config/config.properties |    2 +-
 opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/BuildVersion.java  |    6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/BuildVersion.java b/opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/BuildVersion.java
index 92bfbfe..5d73359 100644
--- a/opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/BuildVersion.java
+++ b/opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/BuildVersion.java
@@ -17,6 +17,7 @@
 package org.forgerock.opendj.config.dsconfig;
 
 import static com.forgerock.opendj.ldap.config.ConfigMessages.*;
+import static com.forgerock.opendj.util.StaticUtils.stackTraceToSingleLineString;
 import static org.forgerock.util.Utils.closeSilently;
 
 import java.io.BufferedReader;
@@ -24,6 +25,7 @@
 import java.io.FileReader;
 import java.io.IOException;
 import java.util.Arrays;
+import java.util.NoSuchElementException;
 
 import org.forgerock.opendj.config.ConfigurationFramework;
 import org.forgerock.opendj.config.server.ConfigException;
@@ -76,8 +78,8 @@
         try {
             final SearchResultEntry entry = connection.readEntry("", "fullVendorVersion");
             return valueOf(entry.getAttribute("fullVendorVersion").firstValueAsString());
-        } catch (LdapException e) {
-            throw new ConfigException(ERR_CONFIGVERSION_NOT_FOUND.get());
+        } catch (NullPointerException | NoSuchElementException |LdapException e) {
+            throw new ConfigException(ERR_CONFIGVERSION_NOT_FOUND.get(stackTraceToSingleLineString(e, false)));
         }
     }
 
diff --git a/opendj-config/src/main/resources/com/forgerock/opendj/ldap/config/config.properties b/opendj-config/src/main/resources/com/forgerock/opendj/ldap/config/config.properties
index 52dfa4b..cbf026f 100644
--- a/opendj-config/src/main/resources/com/forgerock/opendj/ldap/config/config.properties
+++ b/opendj-config/src/main/resources/com/forgerock/opendj/ldap/config/config.properties
@@ -176,4 +176,4 @@
 ERR_BUILDVERSION_NOT_FOUND_737=The version of the installed OpenDJ could not be determined \
 because the version file '%s' could not be found. Restore it from backup before continuing
 ERR_CONFIGVERSION_NOT_FOUND_738=The version of the installed OpenDJ could not be determined \
-because an error occurs during reading the current configuration.
+because an error occurred while reading the current configuration: %s

--
Gitblit v1.10.0