package org.kne.codec.kif;

import java.io.IOException;
import java.util.concurrent.ExecutionException;

public class ExceptionTool {
	public static void throwIOException(Throwable t) throws IOException {
	    if (t == null) {
	        return;
	    }
	    
	    // 递归展开 ExecutionException
	    while (t instanceof ExecutionException && t.getCause() != null) {
	        t = t.getCause();
	    }
	    
	    if (t instanceof IOException) {
	        throw (IOException) t;
	    }
	    if (t instanceof RuntimeException) {
	        throw (RuntimeException) t;
	    }
	    if (t instanceof Error) {
	        throw (Error) t;
	    }
	    
	    throw new IOException(t);
	}
}

