Class ExceptionMapper<X extends Exception>
java.lang.Object
org.opendaylight.yangtools.util.concurrent.ExceptionMapper<X>
- Type Parameters:
X
- the exception type
- Direct Known Subclasses:
ReflectiveExceptionMapper
public abstract class ExceptionMapper<X extends Exception>
extends Object
implements Function<Exception,X>
Utility exception mapper which translates an Exception to a specified type of Exception. This mapper is intended to
be primarily used with
com.google.common.util.concurrent.Futures.makeChecked()
- if exception is the specified type or one of its subclasses, it returns original exception.
- if exception is
ExecutionException
and the cause is of the specified type, it returns the cause - otherwise returns an instance of the specified exception type with original exception as the cause.
- Author:
- Thomas Pantelis
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturn the exception class produced by this instance.protected abstract X
newWithCause
(String message, Throwable cause) Invoked to create a new exception instance of the specified type.
-
Constructor Details
-
ExceptionMapper
Constructor.- Parameters:
opName
- the String prefix for exception messages.exceptionType
- the exception type to which to translate.
-
-
Method Details
-
getExceptionType
Return the exception class produced by this instance.- Returns:
- Exception class.
-
newWithCause
Invoked to create a new exception instance of the specified type.- Parameters:
message
- the message for the new exception.cause
- the cause for the new exception.- Returns:
- an instance of the exception type.
-
apply
-