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 used with
Futures.makeChecked( com.google.common.util.concurrent.ListenableFuture, Function)
- 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 Constructor Description ExceptionMapper(String opName, Class<X> exceptionType)
Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description X
apply(Exception input)
protected Class<X>
getExceptionType()
Return 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.
-
-
-
Method Detail
-
getExceptionType
protected final Class<X> getExceptionType()
Return the exception class produced by this instance.- Returns:
- Exception class.
-
newWithCause
protected abstract X newWithCause(String message, Throwable cause)
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.
-
-