Skip to content

Commit

Permalink
feat: add variables to ThrowError
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisKujawa committed Oct 15, 2023
1 parent c9b17ce commit b060ca0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Client.UnitTests/ThrowErrorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions Client/Api/Commands/IThrowErrorCommandStep1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,13 @@ public interface IThrowErrorCommandStep2 : IFinalCommandWithRetryStep<IThrowErro
/// Call <see cref="IFinalCommandStep{T}.Send"/> to complete the command and send it to the broker.
/// </returns>
IThrowErrorCommandStep2 ErrorMessage(string errorMessage);

/// <summary>
/// Set the variables to send the error with.
/// </summary>
/// <param name="variables">the variables (JSON) as String.</param>
/// <returns>the builder for this command. Call <see cref="IFinalCommandWithRetryStep{T}.Send"/> to complete the command and send it
/// to the broker.</returns>
IThrowErrorCommandStep2 Variables(string variables);
}
}
6 changes: 6 additions & 0 deletions Client/Impl/Commands/ThrowErrorCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ public IThrowErrorCommandStep2 ErrorMessage(string errorMessage)
return this;
}

public IThrowErrorCommandStep2 Variables(string variables)
{
request.Variables = variables;
return this;
}

public async Task<IThrowErrorResponse> Send(TimeSpan? timeout = null, CancellationToken token = default)
{
var asyncReply = gatewayClient.ThrowErrorAsync(request, deadline: timeout?.FromUtcNow(), cancellationToken: token);
Expand Down

0 comments on commit b060ca0

Please sign in to comment.