From b060ca09dbda2ef4e6fb593f79126b2242ba42f7 Mon Sep 17 00:00:00 2001 From: Christopher Zell Date: Sun, 15 Oct 2023 12:32:20 +0200 Subject: [PATCH] feat: add variables to ThrowError --- Client.UnitTests/ThrowErrorTest.cs | 3 +++ Client/Api/Commands/IThrowErrorCommandStep1.cs | 8 ++++++++ Client/Impl/Commands/ThrowErrorCommand.cs | 6 ++++++ 3 files changed, 17 insertions(+) diff --git a/Client.UnitTests/ThrowErrorTest.cs b/Client.UnitTests/ThrowErrorTest.cs index 9dba0995..007d779b 100644 --- a/Client.UnitTests/ThrowErrorTest.cs +++ b/Client.UnitTests/ThrowErrorTest.cs @@ -17,17 +17,20 @@ public async Task ShouldSendRequestAsExpected() const string errorCode = "code 13"; const string errorMessage = "This is a business error!"; const int jobKey = 255; + const string variables = "{\"foo\":23}"; var expectedRequest = new ThrowErrorRequest { JobKey = jobKey, ErrorCode = errorCode, ErrorMessage = errorMessage, + Variables = variables }; // when await ZeebeClient.NewThrowErrorCommand(jobKey) .ErrorCode("code 13") .ErrorMessage("This is a business error!") + .Variables(variables) .Send(); // then diff --git a/Client/Api/Commands/IThrowErrorCommandStep1.cs b/Client/Api/Commands/IThrowErrorCommandStep1.cs index 1a7bd6bf..2e3c8572 100644 --- a/Client/Api/Commands/IThrowErrorCommandStep1.cs +++ b/Client/Api/Commands/IThrowErrorCommandStep1.cs @@ -29,5 +29,13 @@ public interface IThrowErrorCommandStep2 : IFinalCommandWithRetryStep to complete the command and send it to the broker. /// IThrowErrorCommandStep2 ErrorMessage(string errorMessage); + + /// + /// Set the variables to send the error with. + /// + /// the variables (JSON) as String. + /// the builder for this command. Call to complete the command and send it + /// to the broker. + IThrowErrorCommandStep2 Variables(string variables); } } diff --git a/Client/Impl/Commands/ThrowErrorCommand.cs b/Client/Impl/Commands/ThrowErrorCommand.cs index 07a3b22b..434b1350 100644 --- a/Client/Impl/Commands/ThrowErrorCommand.cs +++ b/Client/Impl/Commands/ThrowErrorCommand.cs @@ -52,6 +52,12 @@ public IThrowErrorCommandStep2 ErrorMessage(string errorMessage) return this; } + public IThrowErrorCommandStep2 Variables(string variables) + { + request.Variables = variables; + return this; + } + public async Task Send(TimeSpan? timeout = null, CancellationToken token = default) { var asyncReply = gatewayClient.ThrowErrorAsync(request, deadline: timeout?.FromUtcNow(), cancellationToken: token);