From 5da9d23328d4712728df45d38863723d8e8f7dc1 Mon Sep 17 00:00:00 2001 From: Rick Anderson <3605364+Rick-Anderson@users.noreply.github.com> Date: Mon, 24 Jul 2023 13:03:50 -1000 Subject: [PATCH] Prob details in the right place /5 (#29903) * Prob details in the right place /5 * Prob details in the right place /5 --- aspnetcore/fundamentals/error-handling.md | 2 +- .../error-handling/includes/error-handling3-7.md | 2 +- .../samples/7.x/ErrorHandlingSample/Snippets/Program.cs | 6 +++--- .../samples/8.x/ErrorHandlingSample/Snippets/Program.cs | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/aspnetcore/fundamentals/error-handling.md b/aspnetcore/fundamentals/error-handling.md index 7d3825139d..dc36f9a2a7 100644 --- a/aspnetcore/fundamentals/error-handling.md +++ b/aspnetcore/fundamentals/error-handling.md @@ -261,7 +261,7 @@ For information about how to handle model state errors, see [Model binding](xref The following code configures the app to generate a problem details response for all HTTP client and server error responses that ***don't have a body content yet***: -:::code language="csharp" source="~/fundamentals/error-handling/samples/7.x/ErrorHandlingSample/Snippets/Program.cs" id="snippet_AddProblemDetails" highlight="3"::: +:::code language="csharp" source="~/fundamentals/error-handling/samples/7.x/ErrorHandlingSample/Snippets/Program.cs" id="snippet_AddProblemDetails" highlight="1"::: The next section shows how to customize the problem details response body. diff --git a/aspnetcore/fundamentals/error-handling/includes/error-handling3-7.md b/aspnetcore/fundamentals/error-handling/includes/error-handling3-7.md index faac285f1a..6018b34f31 100644 --- a/aspnetcore/fundamentals/error-handling/includes/error-handling3-7.md +++ b/aspnetcore/fundamentals/error-handling/includes/error-handling3-7.md @@ -221,7 +221,7 @@ For information about how to handle model state errors, see [Model binding](xref The following code configures the app to generate a problem details response for all HTTP client and server error responses that ***don't have a body content yet***: -:::code language="csharp" source="~/fundamentals/error-handling/samples/7.x/ErrorHandlingSample/Snippets/Program.cs" id="snippet_AddProblemDetails" highlight="3"::: +:::code language="csharp" source="~/fundamentals/error-handling/samples/7.x/ErrorHandlingSample/Snippets/Program.cs" id="snippet_AddProblemDetails" highlight="1"::: The next section shows how to customize the problem details response body. diff --git a/aspnetcore/fundamentals/error-handling/samples/7.x/ErrorHandlingSample/Snippets/Program.cs b/aspnetcore/fundamentals/error-handling/samples/7.x/ErrorHandlingSample/Snippets/Program.cs index a865a0958b..a5702a364c 100644 --- a/aspnetcore/fundamentals/error-handling/samples/7.x/ErrorHandlingSample/Snippets/Program.cs +++ b/aspnetcore/fundamentals/error-handling/samples/7.x/ErrorHandlingSample/Snippets/Program.cs @@ -1,4 +1,4 @@ -using Microsoft.AspNetCore.Diagnostics; +using Microsoft.AspNetCore.Diagnostics; using static System.Net.Mime.MediaTypeNames; namespace ErrorHandlingSample.Snippets; @@ -138,10 +138,10 @@ public static class Program public static void AddProblemDetails(WebApplicationBuilder builder) { // - var app = builder.Build(); - builder.Services.AddProblemDetails(); + var app = builder.Build(); + if (!app.Environment.IsDevelopment()) { app.UseExceptionHandler(); diff --git a/aspnetcore/fundamentals/error-handling/samples/8.x/ErrorHandlingSample/Snippets/Program.cs b/aspnetcore/fundamentals/error-handling/samples/8.x/ErrorHandlingSample/Snippets/Program.cs index a865a0958b..a5702a364c 100644 --- a/aspnetcore/fundamentals/error-handling/samples/8.x/ErrorHandlingSample/Snippets/Program.cs +++ b/aspnetcore/fundamentals/error-handling/samples/8.x/ErrorHandlingSample/Snippets/Program.cs @@ -1,4 +1,4 @@ -using Microsoft.AspNetCore.Diagnostics; +using Microsoft.AspNetCore.Diagnostics; using static System.Net.Mime.MediaTypeNames; namespace ErrorHandlingSample.Snippets; @@ -138,10 +138,10 @@ public static class Program public static void AddProblemDetails(WebApplicationBuilder builder) { // - var app = builder.Build(); - builder.Services.AddProblemDetails(); + var app = builder.Build(); + if (!app.Environment.IsDevelopment()) { app.UseExceptionHandler();