Skip to content

Commit

Permalink
improve GRPC exception type and message (#2493)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaibocai authored Jun 16, 2023
1 parent 2960744 commit e6d6e2f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 13 deletions.
33 changes: 20 additions & 13 deletions src/WebJobs.Extensions.DurableTask/LocalGrpcListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,24 +148,31 @@ public override Task<Empty> Hello(Empty request, ServerCallContext context)
ExecutionId = Guid.NewGuid().ToString(),
};

await this.GetDurabilityProvider(context).CreateTaskOrchestrationAsync(
new TaskMessage
{
Event = new ExecutionStartedEvent(-1, request.Input)
try
{
await this.GetDurabilityProvider(context).CreateTaskOrchestrationAsync(
new TaskMessage
{
Name = request.Name,
Version = request.Version,
Event = new ExecutionStartedEvent(-1, request.Input)
{
Name = request.Name,
Version = request.Version,
OrchestrationInstance = instance,
ScheduledStartTime = request.ScheduledStartTimestamp?.ToDateTime(),
},
OrchestrationInstance = instance,
ScheduledStartTime = request.ScheduledStartTimestamp?.ToDateTime(),
},
OrchestrationInstance = instance,
},
this.GetStatusesNotToOverride());
this.GetStatusesNotToOverride());

return new P.CreateInstanceResponse
return new P.CreateInstanceResponse
{
InstanceId = instance.InstanceId,
};
}
catch (InvalidOperationException)
{
InstanceId = instance.InstanceId,
};
throw new RpcException(new Status(StatusCode.AlreadyExists, $"An Orchestration instance with the ID {instance.InstanceId} already exists."));
}
}

public async override Task<P.RaiseEventResponse> RaiseEvent(P.RaiseEventRequest request, ServerCallContext context)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e6d6e2f

Please sign in to comment.