blob: 155490fe8c86cc6dab8f88ac5586f47399392619 (
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
29
30
31
32
|
package org.zwobble.mammoth.internal.util;
import java.io.IOException;
public class PassThroughException extends RuntimeException {
public interface SupplierWithException<T, E extends Throwable> {
public T get() throws E;
}
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;
}
}
|