Create an exception handler in ASP.NET Core 8
Take advantage of the new IExceptionHandler interface to handle exceptions gracefully in your ASP.NET Core applications.
Globalexceptionhandler Ihostenvironment Valuetask Tryhandleasync Httpcontext Httpstatuscode Badrequest Componentmodel Dataannotations Webapplication Createbuilder Mapget Generateerror
Source: infoworld.com