Skip to content

Commit 9245cf6

Browse files
committed
Add DecoderException.DecoderException(String, Object...)
1 parent a1c24b1 commit 9245cf6

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

src/changes/changes.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ The <action> type attribute can be add,update,fix,remove.
5252
<!-- ADD -->
5353
<action type="add" dev="ggregory" due-to="Fredrik Kjellberg, Gary Gregory">Add org.apache.commons.codec.digest.CRC16.</action>
5454
<action type="add" dev="ggregory" due-to="Gary Gregory">Add builders to org.apache.commons.codec.digest streams and deprecate some old constructors.</action>
55+
<action type="add" dev="ggregory" due-to="Gary Gregory">Add DecoderException.DecoderException(String, Object...).</action>
5556
<!-- UPDATE -->
5657
<action type="update" dev="ggregory" due-to="Gary Gregory, Dependabot">Bump org.apache.commons:commons-parent from 85 to 88.</action>
5758
<action type="update" dev="ggregory" due-to="Gary Gregory">[test] Bump org.apache.commons:commons-lang3 from 3.18.0 to 3.19.0.</action>

src/main/java/org/apache/commons/codec/DecoderException.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,20 @@ public DecoderException(final String message) {
5050
super(message);
5151
}
5252

53+
/**
54+
* Constructs a new exception with the specified detail message. The cause is not initialized, and may subsequently be initialized by a call to
55+
* {@link #initCause}.
56+
*
57+
* @param message The format message which is saved for later retrieval by the {@link #getMessage()} method.
58+
* @param args the format arguments to use.
59+
*
60+
* @see String#format(String, Object...)
61+
* @since 1.20
62+
*/
63+
public DecoderException(final String message, Object... args) {
64+
super(String.format(message, args));
65+
}
66+
5367
/**
5468
* Constructs a new exception with the specified detail message and cause.
5569
* <p>

src/test/java/org/apache/commons/codec/DecoderExceptionTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ void testConstructorString() {
4545
assertNull(e.getCause());
4646
}
4747

48+
@Test
49+
void testConstructorStringObjectArray() {
50+
final DecoderException e = new DecoderException("Hello %s", "World!");
51+
assertEquals("Hello World!", e.getMessage());
52+
assertNull(e.getCause());
53+
}
54+
4855
@Test
4956
void testConstructorStringThrowable() {
5057
final DecoderException e = new DecoderException(MSG, t);

0 commit comments

Comments
 (0)