Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/DurableTask.Core/Entities/EventFormat/ResponseMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ internal class ResponseMessage : EntityMessage
public FailureDetails? FailureDetails { get; set; }

[IgnoreDataMember]
public bool IsErrorResult => this.ErrorMessage != null;
public bool IsErrorResult => this.ErrorMessage != null || this.FailureDetails != null;

public override string GetShortDescription()
{
if (this.IsErrorResult)
{
return $"[OperationFailed {this.ErrorMessage} {this.FailureDetails}]";
return $"[OperationFailed {this.FailureDetails?.ErrorMessage ?? this.ErrorMessage}]";
}
else if (this.Result == LockAcquisitionCompletion)
{
Expand Down
14 changes: 11 additions & 3 deletions src/DurableTask.Core/Entities/OperationFormat/OperationResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,27 @@ public class OperationResult

/// <summary>
/// The serialized result returned by the operation. Can be null, if the operation returned no result.
/// May contain error details, such as a serialized exception, if <see cref="ErrorMessage"/> is not null.
/// May contain error details, such as a serialized exception, if <see cref="IsError"/> is true.
/// </summary>
public string? Result { get; set; }

/// <summary>
/// Whether this operation completed successfully.
/// </summary>
public bool IsError
=> this.ErrorMessage != null || this.FailureDetails != null;

/// <summary>
/// If non-null, this string indicates that this operation did not successfully complete.
/// The actual content and its interpretation varies depending on the SDK used.
/// The content and interpretation varies depending on the SDK used. For newer SDKs,
/// we rely on the <see cref="FailureDetails"/> instead.
/// </summary>
public string? ErrorMessage { get; set; }

/// <summary>
/// A structured language-independent representation of the error. Whether this field is present
/// depends on which SDK is used, and on configuration settings.
/// depends on which SDK is used, and on configuration settings. For newer SDKs, we use
/// this field exclusively when collecting error information.
/// </summary>
public FailureDetails? FailureDetails { get; set; }
}
Expand Down
2 changes: 1 addition & 1 deletion src/DurableTask.Core/Logging/LogEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1228,7 +1228,7 @@ public EntityBatchExecuted(EntityBatchRequest request, EntityBatchResult result)
this.InstanceId = request.InstanceId;
this.OperationCount = request.Operations.Count;
this.ResultCount = result.Results.Count;
this.ErrorCount = result.Results.Count(x => x.ErrorMessage != null);
this.ErrorCount = result.Results.Count(x => x.IsError);
this.ActionCount = result.Actions.Count;
this.EntityStateLength = request.EntityState?.Length ?? 0;
}
Expand Down
7 changes: 5 additions & 2 deletions src/DurableTask.Core/TaskEntityDispatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,15 @@ protected async Task<bool> OnProcessWorkItemAsync(TaskOrchestrationWorkItem work

// if we encountered an error, record it as the result of the operations
// so that callers are notified that the operation did not succeed.
if (result.FailureDetails != default(FailureDetails))
if (result.FailureDetails != null)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't default(FailureDetails) the same as null?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but you often use null for reference types for consistency.

{
OperationResult errorResult = new OperationResult()
{
Result = null,
// for older SDKs only
Result = result.FailureDetails.ErrorMessage,
ErrorMessage = "entity dispatch failed",

// for newer SDKs only
FailureDetails = result.FailureDetails,
};

Expand Down