in src/Microsoft.Azure.WebJobs.Extensions.Dapr/Triggers/DaprListenerBase.cs [48:75]
public async Task DispatchAsync(HttpContext context)
{
try
{
await this.DispatchInternalAsync(context);
}
catch (OperationCanceledException) when (context.RequestAborted.IsCancellationRequested)
{
// No-op. This is expected when the request is aborted.
this.Logger.LogWarning("Request was aborted.");
}
catch (Exception ex)
{
if (ex is DaprException || ex is DaprSidecarNotPresentException)
{
this.Logger.LogError(ex, "Function invocation failed with status code {StatusCode}", ((DaprException)ex).StatusCode);
var exception = ex as DaprException;
context.Response.StatusCode = (int)exception!.StatusCode;
await context.Response.WriteAsync(exception!.Message);
}
else
{
this.Logger.LogError(ex, "Function invocation failed.");
context.Response.StatusCode = 500;
await context.Response.WriteAsync($"Function invocation failed: {ex.Message}");
}
}
}