| 
68
 | 
     1 package fschmidt.util.java;
 | 
| 
 | 
     2 
 | 
| 
 | 
     3 import java.util.concurrent.ExecutionException;
 | 
| 
 | 
     4 
 | 
| 
 | 
     5 
 | 
| 
 | 
     6 public final class ComputationException extends RuntimeException {
 | 
| 
 | 
     7 
 | 
| 
 | 
     8 	public ComputationException(Exception e) {
 | 
| 
 | 
     9 		super(e);
 | 
| 
 | 
    10 	}
 | 
| 
 | 
    11 
 | 
| 
 | 
    12 	public static ComputationException newInstance(ExecutionException e) {
 | 
| 
 | 
    13 		Throwable cause = e.getCause();
 | 
| 
 | 
    14 		if( cause instanceof Error )
 | 
| 
 | 
    15 			throw (Error)cause;
 | 
| 
 | 
    16 		if( cause instanceof RuntimeException )
 | 
| 
 | 
    17 			throw (RuntimeException)cause;
 | 
| 
 | 
    18 		if( cause instanceof Exception )
 | 
| 
 | 
    19 			return new ComputationException((Exception)cause);
 | 
| 
 | 
    20 		return new ComputationException(e);
 | 
| 
 | 
    21 	}
 | 
| 
 | 
    22 }
 |