22
22
23
23
import com .fasterxml .jackson .databind .ObjectMapper ;
24
24
import com .google .common .base .Defaults ;
25
+ import com .google .common .base .Preconditions ;
25
26
import io .temporal .api .common .v1 .Payload ;
26
27
import io .temporal .api .common .v1 .Payloads ;
27
28
import io .temporal .api .failure .v1 .Failure ;
28
29
import io .temporal .common .Experimental ;
30
+ import io .temporal .failure .DefaultFailureConverter ;
29
31
import io .temporal .failure .TemporalFailure ;
30
32
import io .temporal .payload .codec .PayloadCodec ;
31
33
import io .temporal .payload .context .SerializationContext ;
@@ -174,7 +176,10 @@ default Object[] fromPayloads(
174
176
* @throws NullPointerException if failure is null
175
177
*/
176
178
@ Nonnull
177
- TemporalFailure failureToException (@ Nonnull Failure failure );
179
+ default TemporalFailure failureToException (@ Nonnull Failure failure ) {
180
+ Preconditions .checkNotNull (failure , "failure" );
181
+ return new DefaultFailureConverter ().failureToException (failure , this );
182
+ }
178
183
179
184
/**
180
185
* Serialize an existing Throwable object into a Failure object. The default implementation
@@ -185,7 +190,10 @@ default Object[] fromPayloads(
185
190
* @throws NullPointerException if throwable is null
186
191
*/
187
192
@ Nonnull
188
- Failure exceptionToFailure (@ Nonnull Throwable throwable );
193
+ default Failure exceptionToFailure (@ Nonnull Throwable throwable ) {
194
+ Preconditions .checkNotNull (throwable , "throwable" );
195
+ return new DefaultFailureConverter ().exceptionToFailure (throwable , this );
196
+ }
189
197
190
198
/**
191
199
* A correct implementation of this interface should have a fully functional "contextless"
0 commit comments