what is the best practice for handling InterruptedException
s when using Throwables.propagate(e) in Guava?
I love using throw Throwables.propagate(e)
, especially in methods that throw no checked exceptions and where exception handling is the responsibility of the caller. But it doesn't do what I'd expect with InterruptedException.
I don't want to lose the fact that the thread was interrupted, so I end up writing things like:
public void run() {
Callable c = ...;
try {
c.call();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw Throwables.propagate(e);
} catch (Exception e) {
throw Throwables.propagate(e);
}
}
Is there a way to do this in Guava? Is there a (backwards compatible?!) way to use something like Throwables.propagate() that sets the thread as interrupted, if it is wrapping and propagating an InterruptedException?