com.greenpepper.util.ExceptionImposter Maven / Gradle / Ivy
package com.greenpepper.util;
/**
* ExceptionImposter class.
*
* @author oaouattara
* @version $Id: $Id
*/
public class ExceptionImposter extends RuntimeException
{
private final Throwable imposterized;
/**
* imposterize.
*
* @param t a {@link java.lang.Throwable} object.
* @return a {@link java.lang.RuntimeException} object.
*/
public static RuntimeException imposterize( Throwable t )
{
if (t instanceof RuntimeException) return (RuntimeException) t;
return new ExceptionImposter( t );
}
/**
* Constructor for ExceptionImposter.
*
* @param e a {@link java.lang.Throwable} object.
*/
public ExceptionImposter(Throwable e)
{
super( e.getMessage(), e.getCause() );
imposterized = e;
setStackTrace( e.getStackTrace() );
}
/**
* getRealException.
*
* @return a {@link java.lang.Throwable} object.
*/
public Throwable getRealException()
{
return imposterized;
}
/**
* toString.
*
* @return a {@link java.lang.String} object.
*/
public String toString()
{
return imposterized.toString();
}
}