Skip to content

Commit 51098cf

Browse files
committed
Fail on WrappedCheckedException constructor validation before calling super
1 parent 7bc5724 commit 51098cf

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

core/src/main/java/com/github/cowwoc/pouch/core/WrappedCheckedException.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import java.util.concurrent.Callable;
66
import java.util.concurrent.ExecutionException;
7+
import static java.util.Objects.requireNonNull;
78

89
/**
910
* A runtime exception dedicated to wrapping checked exceptions.
@@ -21,11 +22,8 @@ public final class WrappedCheckedException extends RuntimeException
2122
*/
2223
private WrappedCheckedException(String message, Throwable cause)
2324
{
24-
super(message, cause);
25-
if (message == null)
26-
throw new NullPointerException("message may not be null");
27-
if (cause == null)
28-
throw new NullPointerException("cause may not be null");
25+
super(requireNonNull(message, "message cannot be null"),
26+
requireNonNull(cause, "cause cannot be null"));
2927
}
3028

3129
/**
@@ -36,9 +34,7 @@ private WrappedCheckedException(String message, Throwable cause)
3634
*/
3735
private WrappedCheckedException(Throwable cause)
3836
{
39-
super(cause);
40-
if (cause == null)
41-
throw new NullPointerException("cause may not be null");
37+
super(requireNonNull(cause, "cause cannot be null"));
4238
}
4339

4440
/**

0 commit comments

Comments
 (0)