feat(commons): wrap IO exception in UncheckedIOException instead of generic RuntimeException
This commit is contained in:
parent
b4ffad5c2c
commit
067f3b9de9
|
@ -3,6 +3,8 @@ package io.gitlab.jfronny.commons.throwable;
|
|||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.util.Objects;
|
||||
import java.util.function.*;
|
||||
|
||||
|
@ -129,6 +131,8 @@ public class Try {
|
|||
@Contract(pure = true)
|
||||
protected static @NotNull RuntimeException runtimeException(@NotNull Throwable t) {
|
||||
Objects.requireNonNull(t);
|
||||
return t instanceof RuntimeException e ? e : new RuntimeException(t);
|
||||
return t instanceof RuntimeException e ? e
|
||||
: t instanceof IOException e ? new UncheckedIOException(e)
|
||||
: new RuntimeException(t);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue