failsafe icon indicating copy to clipboard operation
failsafe copied to clipboard

Add non-wrapped exceptions to get()

Open Gaibhne opened this issue 6 years ago • 1 comments

We talked about this a few days ago; basically, it allows you to properly catch an Exception thrown from code you call in a lambda, like so:

public void testCheckedException() throws IOException {
	RetryPolicy<Object> retryPolicy = new RetryPolicy<>();

	Failsafe.with(retryPolicy).getWithException(() -> {
		throw new IOException();
	});
}

or

RetryPolicy<Object> retryPolicy = new RetryPolicy<>();

try {
	Failsafe.with(retryPolicy).getWithException(() -> {
		throw new IOException();
	});
} catch (IOException e) {
	e.printStackTrace(); // this is horrible practice
}

Obviously the code is not intended to be accepted like this, it's just a POC.

Gaibhne avatar Feb 10 '20 13:02 Gaibhne

Coverage Status

Coverage decreased (-1.8%) to 90.593% when pulling 1dc0c8d95b977329c07cc3de884d01f57387ec6b on Gaibhne:master into 7f411c65dfb29e1b4679a269796a5d1632c8acfc on jhalterman:master.

coveralls avatar Feb 10 '20 13:02 coveralls