Interface FailureConverter

  • All Known Implementing Classes:
    DefaultFailureConverter

    public interface FailureConverter
    A FailureConverter is responsible for converting from proto Failure instances to Java Exception, and back.

    Most users should _never_ need to implement a failure converter. We strongly recommended relying on the DefaultFailureConverter, in order to maintain cross-language Failure serialization compatibility.

    To _encrypt_ the content of failures, see CodecDataConverter instead.

    • Method Detail

      • failureToException

        @Nonnull
        TemporalFailure failureToException​(@Nonnull
                                           io.temporal.api.failure.v1.Failure failure,
                                           @Nonnull
                                           DataConverter dataConverter)
        Instantiate an appropriate Java Exception from a serialized Failure object.
        Parameters:
        failure - Failure protobuf object to deserialize into an exception
        dataConverter - to be used to convert Failure#encodedAttributes and Failure#failure_info#details (if present).
        Returns:
        deserialized exception
        Throws:
        java.lang.NullPointerException - if either failure or dataConverter is null
      • exceptionToFailure

        @Nonnull
        io.temporal.api.failure.v1.Failure exceptionToFailure​(@Nonnull
                                                              java.lang.Throwable throwable,
                                                              @Nonnull
                                                              DataConverter dataConverter)
        Serialize an existing Java Exception into a Failure object.
        Parameters:
        throwable - A Java Exception object to serialize into a Failure protobuf object
        dataConverter - to be used to convert Failure#encodedAttributes and Failure#failure_info#details (if present).
        Returns:
        serialized exception
        Throws:
        java.lang.NullPointerException - if either e or dataConverter is null