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

ml.alternet.misc.WtfException Maven / Gradle / Ivy

Go to download

Alternet Tools include discovery service tools, concurrent and locking tools, and more

The newest version!
package ml.alternet.misc;

/**
 * As the name suggest, an
 * unexpected exception.
 *
 * Use this exception in places where no exception can occur whereas handling an
 * exception is mandatory.
 *
 * For example :
 *
 * 
 * try {
 *     MessageDigest md = MessageDigest.getInstance("MD5");
 *     return md;
 * } catch (NoSuchAlgorithmException e) {
 *     // can't occur since MD5 have to be supported
 *     WtfException.throwException(e);
 * }
 * 
* * @author Philippe Poulard */ public class WtfException extends RuntimeException { private static final long serialVersionUID = -6645630169970707970L; WtfException() { } WtfException(String message) { super(message); } WtfException(String message, Throwable cause) { super(message, cause); } /** * Propagate or create the exception. * * @param cause The cause. * * @return The exception. */ public static WtfException throwException(Throwable cause) { if (cause instanceof WtfException) { return (WtfException) cause; } else { return new WtfException(cause.getMessage(), cause); } } /** * Propagate or create the exception. * * @param message The message. * @param cause The cause. * * @return The exception. */ public static WtfException throwException(String message, Throwable cause) { if (cause instanceof WtfException) { return (WtfException) cause; } else { return new WtfException(message, cause); } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy