Error handling is one of the features that every application must provide. The representation of an error allows the client to understand the error and possibly handle the request accordingly. Very often, we have our own customized methods of handling errors.
Since what we’re describing is a key functionality of the application, we think it’s fair to see what the framework provides and what is more correct to use.
.NET provides the same tool for minimal APIs that we can implement in traditional development: a Developer Exception Page. This is nothing but middleware that reports the error in plain text format. This middleware can’t be removed from the ASP.NET pipeline and works exclusively in the development environment (https://docs.microsoft.com/aspnet/core/fundamentals/error-handling).
Figure 3.13 – Minimal APIs pipeline, ExceptionHandler
If exceptions are raised within our code, the...