Skip to content

Commit b6ca226

Browse files
committed
Generics for Converter should use Exception not Throwable
1 parent 077f021 commit b6ca226

4 files changed

Lines changed: 4 additions & 3 deletions

File tree

src/changes/changes.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
<action type="fix" dev="ggregory" due-to="Gary Gregory">Deprecate DeprecatedAttributes.Builder() in favor of DeprecatedAttributes.builder().</action>
2929
<action type="fix" dev="ggregory" due-to="Dávid Szigecsán">Refactor default parser test #294.</action>
3030
<action type="fix" dev="ggregory" due-to="Gary Gregory">Port to JUnit 5.</action>
31+
<action type="fix" dev="ggregory" due-to="Gary Gregory">Generics for Converter should use Exception not Throwable.</action>
3132
<!-- ADD -->
3233
<action type="add" issue="CLI-339" dev="ggregory" due-to="Claude Warren, Gary Gregory">Help formatter extension in the new package #314.</action>
3334
<action type="add" dev="ggregory" due-to="Gary Gregory">CommandLine.Builder implements Supplier&lt;CommandLine&gt;.</action>

src/main/java/org/apache/commons/cli/CommandLine.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ public <T> T getParsedOptionValue(final Option option, final Supplier<T> default
580580
return get(defaultValue);
581581
}
582582
return (T) option.getConverter().apply(res);
583-
} catch (final Throwable e) {
583+
} catch (final Exception e) {
584584
throw ParseException.wrap(e);
585585
}
586586
}

src/main/java/org/apache/commons/cli/Converter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more
3333
* @since 1.7.0
3434
*/
3535
@FunctionalInterface
36-
public interface Converter<T, E extends Throwable> {
36+
public interface Converter<T, E extends Exception> {
3737
// See also Apache Commons Lang FailableFunction
3838

3939
/**

src/main/java/org/apache/commons/cli/TypeHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public static URL createURL(final String string) throws ParseException {
158158
public static <T> T createValue(final String string, final Class<T> clazz) throws ParseException {
159159
try {
160160
return getDefault().getConverter(clazz).apply(string);
161-
} catch (final Throwable e) {
161+
} catch (final Exception e) {
162162
throw ParseException.wrap(e);
163163
}
164164
}

0 commit comments

Comments
 (0)