This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-configuration.git

commit cd6464ba09c5c9feec2fc45931e522df1d7dcb74
Author: Gary Gregory <[email protected]>
AuthorDate: Fri Apr 3 08:57:50 2026 -0400

    Add and use
    ConfigurationRuntimeException.ConfigurationRuntimeException(Throwable,
    String, Object...)
---
 src/changes/changes.xml                              |  1 +
 .../commons/configuration2/ConfigurationUtils.java   |  4 ++--
 .../configuration2/PropertiesConfiguration.java      |  4 ++--
 .../ex/ConfigurationRuntimeException.java            | 20 ++++++++++++++++----
 .../configuration2/ex/ConversionException.java       |  2 +-
 .../commons/configuration2/interpol/ExprLookup.java  |  2 +-
 .../commons/configuration2/io/VFSFileSystem.java     |  4 ++--
 .../reloading/VFSFileHandlerReloadingDetector.java   |  4 ++--
 .../DatabaseConfigurationTestHelper.java             |  4 ++--
 9 files changed, 29 insertions(+), 16 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 2f71a0ccc..7ee726f9d 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -33,6 +33,7 @@
       <action type="add" dev="ggregory" due-to="Gary Gregory">Add 
ConfigurationException.ConfigurationException(Throwable, String, 
Object...).</action>
       <action type="add" dev="ggregory" due-to="Gary Gregory">Add 
ConversionException.ConversionException(String, Object...).</action>
       <action type="add" dev="ggregory" due-to="Gary Gregory">Add 
ConversionException.ConversionException(Throwable, String, Object...).</action>
+      <action type="add" dev="ggregory" due-to="Gary Gregory">Add 
ConfigurationRuntimeException.ConfigurationRuntimeException(Throwable, String, 
Object...).</action>
       <!-- UPDATE -->
       <action type="update" dev="ggregory" due-to="Gary Gregory">Bump 
org.apache.commons:commons-parent from 92 to 97.</action>
       <action type="update" dev="ggregory" due-to="Gary Gregory">Bump 
org.apache.commons:commons-text from 1.14.0 to 1.15.0.</action>
diff --git 
a/src/main/java/org/apache/commons/configuration2/ConfigurationUtils.java 
b/src/main/java/org/apache/commons/configuration2/ConfigurationUtils.java
index c6c56bc8d..c4a6c59c9 100644
--- a/src/main/java/org/apache/commons/configuration2/ConfigurationUtils.java
+++ b/src/main/java/org/apache/commons/configuration2/ConfigurationUtils.java
@@ -446,8 +446,8 @@ public final class ConfigurationUtils {
     public static Class<?> loadClassNoEx(final String clsName) {
         try {
             return loadClass(clsName);
-        } catch (final ClassNotFoundException cnfex) {
-            throw new ConfigurationRuntimeException("Cannot load class " + 
clsName, cnfex);
+        } catch (final ClassNotFoundException e) {
+            throw new ConfigurationRuntimeException(e, "Cannot load class %s", 
clsName);
         }
     }
 
diff --git 
a/src/main/java/org/apache/commons/configuration2/PropertiesConfiguration.java 
b/src/main/java/org/apache/commons/configuration2/PropertiesConfiguration.java
index 776554f43..c1ac7c2df 100644
--- 
a/src/main/java/org/apache/commons/configuration2/PropertiesConfiguration.java
+++ 
b/src/main/java/org/apache/commons/configuration2/PropertiesConfiguration.java
@@ -1181,8 +1181,8 @@ public class PropertiesConfiguration extends 
BaseConfiguration implements FileBa
                         unicode.setLength(0);
                         inUnicode = false;
                         hadSlash = false;
-                    } catch (final NumberFormatException nfe) {
-                        throw new ConfigurationRuntimeException("Unable to 
parse unicode value: " + unicode, nfe);
+                    } catch (final NumberFormatException e) {
+                        throw new ConfigurationRuntimeException(e, "Unable to 
parse unicode value: %s", unicode);
                     }
                 }
                 continue;
diff --git 
a/src/main/java/org/apache/commons/configuration2/ex/ConfigurationRuntimeException.java
 
b/src/main/java/org/apache/commons/configuration2/ex/ConfigurationRuntimeException.java
index 9a886ff15..729d4b6a5 100644
--- 
a/src/main/java/org/apache/commons/configuration2/ex/ConfigurationRuntimeException.java
+++ 
b/src/main/java/org/apache/commons/configuration2/ex/ConfigurationRuntimeException.java
@@ -45,11 +45,10 @@ public class ConfigurationRuntimeException extends 
RuntimeException {
     }
 
     /**
-     * Constructs a new {@code ConfigurationRuntimeException} with specified 
detail message using
-     * {@link String#format(String,Object...)}.
+     * Constructs a new {@code ConfigurationRuntimeException} with specified 
detail message using {@link String#format(String,Object...)}.
      *
      * @param message the error message
-     * @param args arguments to the error message
+     * @param args    arguments to the error message
      * @see String#format(String,Object...)
      */
     public ConfigurationRuntimeException(final String message, final Object... 
args) {
@@ -60,7 +59,7 @@ public class ConfigurationRuntimeException extends 
RuntimeException {
      * Constructs a new {@code ConfigurationRuntimeException} with specified 
detail message and nested {@code Throwable}.
      *
      * @param message the error message
-     * @param cause the exception or error that caused this exception to be 
thrown
+     * @param cause   the exception or error that caused this exception to be 
thrown
      */
     public ConfigurationRuntimeException(final String message, final Throwable 
cause) {
         super(message, cause);
@@ -74,4 +73,17 @@ public class ConfigurationRuntimeException extends 
RuntimeException {
     public ConfigurationRuntimeException(final Throwable cause) {
         super(cause);
     }
+
+    /**
+     * Constructs a new {@code ConfigurationRuntimeException} with specified 
detail message.
+     *
+     * @param format the error message for for {@link String#format(String, 
Object...)}.
+     * @param params the error parameters for for {@link String#format(String, 
Object...)}.
+     * @param cause  the cause (which is saved for later retrieval by the 
{@link #getCause()} method). (A {@code null} value is permitted, and indicates 
that
+     *               the cause is nonexistent or unknown.)
+     * @since 2.14.0
+     */
+    public ConfigurationRuntimeException(final Throwable cause, final String 
format, final Object... params) {
+        super(String.format(format, params), cause);
+    }
 }
diff --git 
a/src/main/java/org/apache/commons/configuration2/ex/ConversionException.java 
b/src/main/java/org/apache/commons/configuration2/ex/ConversionException.java
index b1a6726b1..7b2bd6f20 100644
--- 
a/src/main/java/org/apache/commons/configuration2/ex/ConversionException.java
+++ 
b/src/main/java/org/apache/commons/configuration2/ex/ConversionException.java
@@ -84,6 +84,6 @@ public class ConversionException extends 
ConfigurationRuntimeException {
      * @since 2.14.0
      */
     public ConversionException(final Throwable cause, final String format, 
final Object... params) {
-        super(String.format(format, params), cause);
+        super(cause, format, params);
     }
 }
diff --git 
a/src/main/java/org/apache/commons/configuration2/interpol/ExprLookup.java 
b/src/main/java/org/apache/commons/configuration2/interpol/ExprLookup.java
index 670364079..f46f96666 100644
--- a/src/main/java/org/apache/commons/configuration2/interpol/ExprLookup.java
+++ b/src/main/java/org/apache/commons/configuration2/interpol/ExprLookup.java
@@ -140,7 +140,7 @@ public class ExprLookup implements Lookup {
                     this.value = clazz;
                 }
             } catch (final Exception e) {
-                throw new ConfigurationRuntimeException("Unable to create " + 
value, e);
+                throw new ConfigurationRuntimeException(e, "Unable to create 
%s", value);
             }
 
         }
diff --git 
a/src/main/java/org/apache/commons/configuration2/io/VFSFileSystem.java 
b/src/main/java/org/apache/commons/configuration2/io/VFSFileSystem.java
index 2a13459ae..002ffc1dd 100644
--- a/src/main/java/org/apache/commons/configuration2/io/VFSFileSystem.java
+++ b/src/main/java/org/apache/commons/configuration2/io/VFSFileSystem.java
@@ -222,8 +222,8 @@ public class VFSFileSystem extends DefaultFileSystem {
 
             final URLStreamHandler handler = new VFSURLStreamHandler();
             return new URL(null, path.getURI(), handler);
-        } catch (final FileSystemException fse) {
-            throw new ConfigurationRuntimeException("Could not parse basePath: 
" + basePath + " and fileName: " + file, fse);
+        } catch (final FileSystemException e) {
+            throw new ConfigurationRuntimeException(e, "Could not parse 
basePath: %s and fileName: %s", basePath, file);
         }
     }
 
diff --git 
a/src/main/java/org/apache/commons/configuration2/reloading/VFSFileHandlerReloadingDetector.java
 
b/src/main/java/org/apache/commons/configuration2/reloading/VFSFileHandlerReloadingDetector.java
index a5876be24..f6808b80e 100644
--- 
a/src/main/java/org/apache/commons/configuration2/reloading/VFSFileHandlerReloadingDetector.java
+++ 
b/src/main/java/org/apache/commons/configuration2/reloading/VFSFileHandlerReloadingDetector.java
@@ -93,10 +93,10 @@ public class VFSFileHandlerReloadingDetector extends 
FileHandlerReloadingDetecto
                 throw new ConfigurationRuntimeException("Unable to determine 
file to monitor");
             }
             return fsManager.resolveFile(uri);
-        } catch (final FileSystemException fse) {
+        } catch (final FileSystemException e) {
             final String msg = "Unable to monitor " + 
getFileHandler().getURL().toString();
             log.error(msg);
-            throw new ConfigurationRuntimeException(msg, fse);
+            throw new ConfigurationRuntimeException(msg, e);
         }
     }
 
diff --git 
a/src/test/java/org/apache/commons/configuration2/DatabaseConfigurationTestHelper.java
 
b/src/test/java/org/apache/commons/configuration2/DatabaseConfigurationTestHelper.java
index 88a8d5dd8..5fe6c71b9 100644
--- 
a/src/test/java/org/apache/commons/configuration2/DatabaseConfigurationTestHelper.java
+++ 
b/src/test/java/org/apache/commons/configuration2/DatabaseConfigurationTestHelper.java
@@ -106,8 +106,8 @@ public class DatabaseConfigurationTestHelper {
         if (dataSource == null) {
             try {
                 dataSource = setUpDataSource();
-            } catch (final Exception ex) {
-                throw new ConfigurationRuntimeException("Could not create data 
source", ex);
+            } catch (final Exception e) {
+                throw new ConfigurationRuntimeException("Could not create data 
source", e);
             }
         }
         return dataSource;

Reply via email to