Skip to content

Commit 87239a1

Browse files
authored
Log caught exception in LocalGrpcListener's CreateInstance method (#2779)
1 parent 49d8656 commit 87239a1

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/WebJobs.Extensions.DurableTask/LocalGrpcListener.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using System.Threading.Tasks;
1111
using DurableTask.Core;
1212
using DurableTask.Core.Entities;
13+
using DurableTask.Core.Exceptions;
1314
using DurableTask.Core.History;
1415
using DurableTask.Core.Query;
1516
using DurableTask.Core.Serializing.Internal;
@@ -161,10 +162,23 @@ public override Task<Empty> Hello(Empty request, ServerCallContext context)
161162
InstanceId = instanceId,
162163
};
163164
}
164-
catch (InvalidOperationException)
165+
catch (OrchestrationAlreadyExistsException)
165166
{
166167
throw new RpcException(new Status(StatusCode.AlreadyExists, $"An Orchestration instance with the ID {request.InstanceId} already exists."));
167168
}
169+
catch (InvalidOperationException ex) when (ex.Message.EndsWith("already exists.")) // for older versions of DTF.AS and DTFx.Netherite
170+
{
171+
throw new RpcException(new Status(StatusCode.AlreadyExists, $"An Orchestration instance with the ID {request.InstanceId} already exists."));
172+
}
173+
catch (Exception ex)
174+
{
175+
this.extension.TraceHelper.ExtensionWarningEvent(
176+
this.extension.Options.HubName,
177+
functionName: request.Name,
178+
instanceId: request.InstanceId,
179+
message: $"Failed to start instanceId {request.InstanceId} due to internal exception.\n Exception trace: {ex}.");
180+
throw new RpcException(new Status(StatusCode.Internal, $"Failed to start instance with ID {request.InstanceId}.\nInner Exception message: {ex.Message}."));
181+
}
168182
}
169183

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

0 commit comments

Comments
 (0)