From 6c5cebbaf86979b1be8ab7387ca64ce2a7d336ce Mon Sep 17 00:00:00 2001 From: Safia Abdalla Date: Wed, 23 Jun 2021 18:32:11 -0700 Subject: [PATCH 1/2] Add docs on generating ProblemDetails payload --- aspnetcore/web-api/handle-errors.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/aspnetcore/web-api/handle-errors.md b/aspnetcore/web-api/handle-errors.md index 966a607df7..07f5b713db 100644 --- a/aspnetcore/web-api/handle-errors.md +++ b/aspnetcore/web-api/handle-errors.md @@ -328,3 +328,9 @@ Use the ## Custom Middleware to handle exceptions The defaults in the exception handling middleware works well for most apps. For apps that require specialized exception handling, consider [customizing the exception handling middleware](xref:fundamentals/error-handling#exception-handler-lambda). + +### Producing a ProblemDetails payload for exceptions + +ASP.NET Core does not produce stanardized error payload when the server encounters an unhandled exception. For scenarios where it is desireable to return a standardized [ProblemDetails response](https://datatracker.ietf.org/doc/html/rfc7807) to the client, the [ProblemDetails middleware](https://www.nuget.org/packages/Hellang.Middleware.ProblemDetails/) can be used to map exceptions and 404s to a ProblemDetails payload. The exception handling middleware can also be used to return a ProblemDetails payload for unhandled exceptions. + + From 6a8760c45f78ab610eb76f5546186f3bfb2b1ad2 Mon Sep 17 00:00:00 2001 From: Safia Abdalla Date: Wed, 23 Jun 2021 20:27:42 -0700 Subject: [PATCH 2/2] Update aspnetcore/web-api/handle-errors.md Co-authored-by: Rick Anderson <3605364+Rick-Anderson@users.noreply.github.com> --- aspnetcore/web-api/handle-errors.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/aspnetcore/web-api/handle-errors.md b/aspnetcore/web-api/handle-errors.md index 07f5b713db..dbbf5a45af 100644 --- a/aspnetcore/web-api/handle-errors.md +++ b/aspnetcore/web-api/handle-errors.md @@ -331,6 +331,5 @@ The defaults in the exception handling middleware works well for most apps. For ### Producing a ProblemDetails payload for exceptions -ASP.NET Core does not produce stanardized error payload when the server encounters an unhandled exception. For scenarios where it is desireable to return a standardized [ProblemDetails response](https://datatracker.ietf.org/doc/html/rfc7807) to the client, the [ProblemDetails middleware](https://www.nuget.org/packages/Hellang.Middleware.ProblemDetails/) can be used to map exceptions and 404s to a ProblemDetails payload. The exception handling middleware can also be used to return a ProblemDetails payload for unhandled exceptions. - +ASP.NET Core doesn't produce a standardized error payload when the server encounters an unhandled exception. For scenarios where it is desireable to return a standardized [ProblemDetails response](https://datatracker.ietf.org/doc/html/rfc7807) to the client, the [ProblemDetails middleware](https://www.nuget.org/packages/Hellang.Middleware.ProblemDetails/) can be used to map exceptions and 404s to a [ProblemDetails](xref:web-api/handle-errors#pd) payload. The exception handling middleware can also be used to return a payload for unhandled exceptions.