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-cli.git


The following commit(s) were added to refs/heads/master by this push:
     new b6ca226a Generics for Converter should use Exception not Throwable
b6ca226a is described below

commit b6ca226a56734563e18626670bf35fa96971181e
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Tue Nov 12 14:30:02 2024 -0500

    Generics for Converter should use Exception not Throwable
---
 src/changes/changes.xml                               | 1 +
 src/main/java/org/apache/commons/cli/CommandLine.java | 2 +-
 src/main/java/org/apache/commons/cli/Converter.java   | 2 +-
 src/main/java/org/apache/commons/cli/TypeHandler.java | 2 +-
 4 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 11fc5d63..31373da7 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -28,6 +28,7 @@
       <action type="fix" dev="ggregory" due-to="Gary Gregory">Deprecate 
DeprecatedAttributes.Builder() in favor of 
DeprecatedAttributes.builder().</action>
       <action type="fix" dev="ggregory" due-to="Dávid Szigecsán">Refactor 
default parser test #294.</action>
       <action type="fix" dev="ggregory" due-to="Gary Gregory">Port to JUnit 
5.</action>
+      <action type="fix" dev="ggregory" due-to="Gary Gregory">Generics for 
Converter should use Exception not Throwable.</action>
       <!-- ADD -->
       <action type="add" issue="CLI-339" dev="ggregory" due-to="Claude Warren, 
Gary Gregory">Help formatter extension in the new package #314.</action>
       <action type="add" dev="ggregory" due-to="Gary 
Gregory">CommandLine.Builder implements Supplier&lt;CommandLine&gt;.</action>
diff --git a/src/main/java/org/apache/commons/cli/CommandLine.java 
b/src/main/java/org/apache/commons/cli/CommandLine.java
index ef2a119d..00defd1a 100644
--- a/src/main/java/org/apache/commons/cli/CommandLine.java
+++ b/src/main/java/org/apache/commons/cli/CommandLine.java
@@ -580,7 +580,7 @@ public class CommandLine implements Serializable {
                 return get(defaultValue);
             }
             return (T) option.getConverter().apply(res);
-        } catch (final Throwable e) {
+        } catch (final Exception e) {
             throw ParseException.wrap(e);
         }
     }
diff --git a/src/main/java/org/apache/commons/cli/Converter.java 
b/src/main/java/org/apache/commons/cli/Converter.java
index 09d7760b..e4d18951 100644
--- a/src/main/java/org/apache/commons/cli/Converter.java
+++ b/src/main/java/org/apache/commons/cli/Converter.java
@@ -33,7 +33,7 @@ import java.util.Date;
  * @since 1.7.0
  */
 @FunctionalInterface
-public interface Converter<T, E extends Throwable> {
+public interface Converter<T, E extends Exception> {
     // See also Apache Commons Lang FailableFunction
 
     /**
diff --git a/src/main/java/org/apache/commons/cli/TypeHandler.java 
b/src/main/java/org/apache/commons/cli/TypeHandler.java
index 3ec9a519..40f864ea 100644
--- a/src/main/java/org/apache/commons/cli/TypeHandler.java
+++ b/src/main/java/org/apache/commons/cli/TypeHandler.java
@@ -158,7 +158,7 @@ public class TypeHandler {
     public static <T> T createValue(final String string, final Class<T> clazz) 
throws ParseException {
         try {
             return getDefault().getConverter(clazz).apply(string);
-        } catch (final Throwable e) {
+        } catch (final Exception e) {
             throw ParseException.wrap(e);
         }
     }

Reply via email to