Created
          September 1, 2010 23:51 
        
      - 
      
- 
        Save toluju/561592 to your computer and use it in GitHub Desktop. 
    Generic Exceptions suck
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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