From 238ca06e4db3ec67e6c8cec2a314dd339ffa3b7c Mon Sep 17 00:00:00 2001 From: Quinn Klassen Date: Thu, 3 Oct 2024 12:46:00 -0700 Subject: [PATCH] Include failure message in Nexus exception (#2251) --- .../failure/DefaultFailureConverter.java | 1 + .../temporal/failure/NexusOperationFailure.java | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/temporal-sdk/src/main/java/io/temporal/failure/DefaultFailureConverter.java b/temporal-sdk/src/main/java/io/temporal/failure/DefaultFailureConverter.java index 9246a342d..87b54e761 100644 --- a/temporal-sdk/src/main/java/io/temporal/failure/DefaultFailureConverter.java +++ b/temporal-sdk/src/main/java/io/temporal/failure/DefaultFailureConverter.java @@ -179,6 +179,7 @@ private TemporalFailure failureToExceptionImpl(Failure failure, DataConverter da { NexusOperationFailureInfo info = failure.getNexusOperationExecutionFailureInfo(); return new NexusOperationFailure( + failure.getMessage(), info.getScheduledEventId(), info.getEndpoint(), info.getService(), diff --git a/temporal-sdk/src/main/java/io/temporal/failure/NexusOperationFailure.java b/temporal-sdk/src/main/java/io/temporal/failure/NexusOperationFailure.java index 48de781cc..634435bb4 100644 --- a/temporal-sdk/src/main/java/io/temporal/failure/NexusOperationFailure.java +++ b/temporal-sdk/src/main/java/io/temporal/failure/NexusOperationFailure.java @@ -38,13 +38,17 @@ public final class NexusOperationFailure extends TemporalFailure { private final String operationId; public NexusOperationFailure( + String message, long scheduledEventId, String endpoint, String service, String operation, String operationId, Throwable cause) { - super(getMessage(scheduledEventId, endpoint, service, operation, operationId), null, cause); + super( + getMessage(message, scheduledEventId, endpoint, service, operation, operationId), + message, + cause); this.scheduledEventId = scheduledEventId; this.endpoint = endpoint; this.service = service; @@ -53,6 +57,7 @@ public NexusOperationFailure( } public static String getMessage( + String originalMessage, long scheduledEventId, String endpoint, String service, @@ -60,9 +65,16 @@ public static String getMessage( String operationId) { return "Nexus Operation with operation='" + operation + + "service='" + + service + + "' endpoint='" + + endpoint + + "' failed: '" + + originalMessage + "'. " + "scheduledEventId=" - + scheduledEventId; + + scheduledEventId + + (operationId == null ? "" : ", operationId=" + operationId); } public long getScheduledEventId() {