Skip to content

Instantly share code, notes, and snippets.

@toluju
Created September 1, 2010 23:51
Show Gist options
  • Save toluju/561592 to your computer and use it in GitHub Desktop.
Save toluju/561592 to your computer and use it in GitHub Desktop.
Generic Exceptions suck
public interface Request<R, E extends Exception> {
public R process() throws E;
}
public class Processor {
public <R, E extends Exception> R process(Request<R, E> request) throws E {
E lastException = null;
for (int x = 0; x < retries; ++x {
try {
return request.process();
}
catch (E e) {
lastException = e;
}
}
throw lastException;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment