Interface ThrowableSurrogateFactory<Ex extends Throwable>

    • Method Detail

      • newSurrogate

        Ex newSurrogate​(Ex template,
                        Throwable cause)
        Creates a new Throwable surrogate, when possible to create with a compatible state.
        Parameters:
        template - The created surrogate must be of the same type as the template, and must include all template-type-specific state. If unable to copy the state, then no surrogate should be created.
        cause - The cause that should be used for the newly created surrogate. This may or may not be the same as the template. This may or may not have the template in its change of causes or suppression lists. It is allowed to further wrap the cause if necessary to create the surrogate, such as with WrappedException or WrappedError.
        Returns:
        A new throwable instance of the same type as the template, with compatible state, and the given cause either directly or wrapped. If unable to create a compatible surrogate, returns null.