Class ExceptionUtil
- java.lang.Object
-
- com.github.toolarium.enumeration.configuration.util.ExceptionUtil
-
public final class ExceptionUtil extends java.lang.Object
Exception utility
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ExceptionUtil
getInstance()
Get the instancejava.lang.String
prepareExceptionWithStacktraceInMessage(java.lang.Exception ex)
Prepare the exception messagejava.lang.String
prepareStacktraceInMessage(java.lang.Exception ex, java.lang.String filterPackage)
Throws a defined exception<E extends java.lang.Exception>
EthrowExceptionWithStacktraceInMessage(java.lang.Exception ex, java.lang.Class<E> exceptionClass)
Throws a defined exception<E extends java.lang.Exception>
EthrowExceptionWithStacktraceInMessage(java.lang.Exception ex, java.lang.Class<E> exceptionClass, java.lang.String filterPackage)
Throws a defined exception<E extends java.lang.Exception>
EthrowsException(java.lang.Class<E> exceptionClass, java.lang.String message)
Throws an exception with a specific message<E extends java.lang.Exception>
EthrowsException(java.lang.Class<E> exceptionClass, java.lang.String message, java.lang.StackTraceElement[] stackTraceElement)
Throws an exception with a specific message<E extends java.lang.Exception>
EthrowsException(java.lang.Exception ex, java.lang.Class<E> exceptionClass, boolean withStacktrace)
Throws an exception with a specific message
-
-
-
Method Detail
-
getInstance
public static ExceptionUtil getInstance()
Get the instance- Returns:
- the instance
-
prepareExceptionWithStacktraceInMessage
public java.lang.String prepareExceptionWithStacktraceInMessage(java.lang.Exception ex)
Prepare the exception message- Parameters:
ex
- the exception- Returns:
- the message
-
prepareStacktraceInMessage
public java.lang.String prepareStacktraceInMessage(java.lang.Exception ex, java.lang.String filterPackage)
Throws a defined exception- Parameters:
ex
- the exceptionfilterPackage
- the package filter- Returns:
- the message
-
throwExceptionWithStacktraceInMessage
public <E extends java.lang.Exception> E throwExceptionWithStacktraceInMessage(java.lang.Exception ex, java.lang.Class<E> exceptionClass)
Throws a defined exception- Type Parameters:
E
- the exception type- Parameters:
ex
- the exceptionexceptionClass
- the new exception class- Returns:
- the exception
-
throwExceptionWithStacktraceInMessage
public <E extends java.lang.Exception> E throwExceptionWithStacktraceInMessage(java.lang.Exception ex, java.lang.Class<E> exceptionClass, java.lang.String filterPackage)
Throws a defined exception- Type Parameters:
E
- the exception type- Parameters:
ex
- the exceptionexceptionClass
- the new exception classfilterPackage
- the package filter- Returns:
- the exception
-
throwsException
public <E extends java.lang.Exception> E throwsException(java.lang.Exception ex, java.lang.Class<E> exceptionClass, boolean withStacktrace)
Throws an exception with a specific message- Type Parameters:
E
- the exception type- Parameters:
ex
- the exceptionexceptionClass
- the exception classwithStacktrace
- true to add the stacktrace- Returns:
- the exception
- Throws:
java.lang.IllegalStateException
- In case of an invalid state
-
throwsException
public <E extends java.lang.Exception> E throwsException(java.lang.Class<E> exceptionClass, java.lang.String message)
Throws an exception with a specific message- Type Parameters:
E
- the exception type- Parameters:
exceptionClass
- the exception classmessage
- the message- Returns:
- the exception
- Throws:
java.lang.IllegalArgumentException
- In case of an invalid state
-
throwsException
public <E extends java.lang.Exception> E throwsException(java.lang.Class<E> exceptionClass, java.lang.String message, java.lang.StackTraceElement[] stackTraceElement)
Throws an exception with a specific message- Type Parameters:
E
- the exception type- Parameters:
exceptionClass
- the exception classmessage
- the messagestackTraceElement
- the stacktrace element- Returns:
- the exception
- Throws:
java.lang.IllegalArgumentException
- In case of an invalid state
-
-