Skip to content

Commit

Permalink
Add more explanation for Option 2
Browse files Browse the repository at this point in the history
  • Loading branch information
christoment committed Oct 3, 2023
1 parent 74bfff9 commit b01d4d7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions rules/do-you-return-detailed-error-messages/rule.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@ The default .NET Exception Handler middleware will **only** produce ProblemDetai

### Option 2 - Customise Exception Handler Middleware (Recommended)

This option provides more flexibility in controlling how the ProblemDetails.
Read more about it [here](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/error-handling?view=aspnetcore-8.0&preserve-view=true#exception-handler-lambda)
This option provides more flexibility in controlling the API's behaviour when it encounters thrown exceptions. Read more about it [here](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/error-handling?view=aspnetcore-8.0&preserve-view=true#exception-handler-lambda).
By Customising the `ExceptionHandler` middleware, developers have complete control over what format endpoints should return under a particular scenario.

Below is an example of customising the `ExceptionHandler` middleware to produce a `ProblemDetails` response for any exception.

```csharp
app.UseExceptionHandler(exceptionHandlerApp =>
Expand Down

0 comments on commit b01d4d7

Please sign in to comment.