All Downloads are FREE. Search and download functionalities are using the official Maven repository.

aQute.lib.exceptions.Exceptions Maven / Gradle / Ivy

The newest version!
package aQute.lib.exceptions;

import java.io.PrintWriter;
import java.io.StringWriter;

public class Exceptions {
	private Exceptions() {}

	public static RuntimeException duck(Throwable t) {
		Exceptions.throwsUnchecked(t);
		throw new AssertionError("unreachable");
	}

	@SuppressWarnings("unchecked")
	private static  void throwsUnchecked(Throwable throwable) throws E {
		throw (E) throwable;
	}

	public static String toString(Throwable t) {
		StringWriter sw = new StringWriter();
		t.printStackTrace(new PrintWriter(sw));
		return sw.toString();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy