Skip to content

Commit

Permalink
Generics for Converter should use Exception not Throwable
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed Nov 12, 2024
1 parent 077f021 commit b6ca226
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/apache/commons/cli/CommandLine.java
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ public <T> T getParsedOptionValue(final Option option, final Supplier<T> default
return get(defaultValue);
}
return (T) option.getConverter().apply(res);
} catch (final Throwable e) {
} catch (final Exception e) {
throw ParseException.wrap(e);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/apache/commons/cli/Converter.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more
* @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

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/apache/commons/cli/TypeHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public static URL createURL(final String string) throws ParseException {
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);
}
}
Expand Down

0 comments on commit b6ca226

Please sign in to comment.