blob: c25ddf989533e849f7ca2f2f74957e9f9665903e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
package org.zwobble.mammoth.internal.util;
import java.io.IOException;
public class PassThroughException extends RuntimeException {
public static <T> T wrap(SupplierWithException<T, IOException> supplier) {
try {
return supplier.get();
} catch (IOException exception) {
throw new PassThroughException(exception);
}
}
public static <T> T unwrap(SupplierWithException<T, IOException> supplier) throws IOException {
try {
return supplier.get();
} catch (PassThroughException exception) {
throw exception.exception;
}
}
private final IOException exception;
public PassThroughException(IOException exception) {
super(exception);
this.exception = exception;
}
}
|