Interface ThrowableCreatingCallable<V,T extends Throwable>
-
- Type Parameters:
V
- The type of result of the method to call.T
- The type of the throwable to be created.
- All Superinterfaces:
Callable<V>
public interface ThrowableCreatingCallable<V,T extends Throwable> extends Callable<V>
This interface encapsulates the creation of a new throwable based on an occurred throwable. The purpose is to create a new throwable replacing the occurred throwable because the occurred throwable may refer to a class that is not available where the throwable is handled. For instance JDBC exceptions may be specific to a driver. If these occur at the server, they usually cannot reach the client since a client does not have any class from the driver and therefore also not the exception class. When replacing the throwable, the log level can be set to use for the exception. This prevents minor exceptions from being logged as severe.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Pair<? extends T,Level>
replaceThrowable(String msg, Throwable thrown)
Creates a new throwable replacing the designated throwable.
-
-
-
Method Detail
-
replaceThrowable
Pair<? extends T,Level> replaceThrowable(String msg, Throwable thrown)
Creates a new throwable replacing the designated throwable. Usually you should use the designated message for the created throwable.You must not re-use or wrap the designated throwable! This is allowing to differentiate the replacing throwable. But make sure the replacing throwable is compatible to all possible clients calling the actual
method
.- Parameters:
msg
- The message that should be used for the created replacing throwable.thrown
- The occurred throwable that should be replaced by a different one. You must not re-use or wrap this in the replacing throwable.- Returns:
- A new throwable replacing the designated one. Make that it is compatible to all
possible clients calling the actual
method
. Additionally, the log level to use for the exception can be returned. If the log level isnull
,Level.SEVERE
will be used.
-
-