Class ReflectiveExceptionMapper<X extends Exception>
java.lang.Object
org.opendaylight.yangtools.util.concurrent.ExceptionMapper<X>
org.opendaylight.yangtools.util.concurrent.ReflectiveExceptionMapper<X>
- Type Parameters:
X
- Exception type
Convenience
ExceptionMapper
which instantiates specified Exception using
reflection. The Exception types are expected to declare an accessible constructor
which takes two arguments: a String and a Throwable.-
Method Summary
Modifier and TypeMethodDescriptionstatic <X extends Exception>
ReflectiveExceptionMapper<X>Create a new instance of the reflective exception mapper.protected X
newWithCause
(String message, Throwable cause) Invoked to create a new exception instance of the specified type.Methods inherited from class org.opendaylight.yangtools.util.concurrent.ExceptionMapper
apply, getExceptionType
-
Method Details
-
newWithCause
Description copied from class:ExceptionMapper
Invoked to create a new exception instance of the specified type.- Specified by:
newWithCause
in classExceptionMapper<X extends Exception>
- Parameters:
message
- the message for the new exception.cause
- the cause for the new exception.- Returns:
- an instance of the exception type.
-
create
public static <X extends Exception> ReflectiveExceptionMapper<X> create(String opName, Class<X> exceptionType) Create a new instance of the reflective exception mapper. This method performs basic sanity checking on the exception class. This method is potentially very costly, so users are strongly encouraged to cache the returned mapper for reuse.- Parameters:
opName
- Operation performedexceptionType
- Exception type- Returns:
- A new mapper instance
- Throws:
IllegalArgumentException
- when the supplied exception class does not pass sanity checksSecurityException
- when the required constructor is not accessible
-