Skip to content

Commit

Permalink
Convert Microsoft.AspNetCore exceptions to errors.
Browse files Browse the repository at this point in the history
This handles Microsoft.AspNetCore.Server.Kestrel.BadHttpRequestException, which can be thrown when hosting a ASP.NET Core API under Kestrel on Linux.

See dotnet/aspnetcore#20614 for the rationale behind the multiple namespaces.
  • Loading branch information
bgrainger committed May 9, 2024
1 parent f3e7284 commit 2f56c04
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Facility.Core/Http/ServiceHttpHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,11 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
/// <summary>
/// Called to determine if an error object should be created from an unexpected exception.
/// </summary>
protected virtual bool ShouldCreateErrorFromException(Exception exception)
{
var exceptionTypeName = exception.GetType().FullName;
return exceptionTypeName != null && exceptionTypeName.StartsWith("System.Web.", StringComparison.Ordinal);
}
protected virtual bool ShouldCreateErrorFromException(Exception exception) =>
exception.GetType().FullName is { } exceptionTypeName && (
exceptionTypeName.StartsWith("Microsoft.AspNetCore.Http.", StringComparison.Ordinal) ||
exceptionTypeName.StartsWith("Microsoft.AspNetCore.Server.", StringComparison.Ordinal) ||
exceptionTypeName.StartsWith("System.Web.", StringComparison.Ordinal));

/// <summary>
/// Called to create an error object from an unexpected exception.
Expand Down

0 comments on commit 2f56c04

Please sign in to comment.