Stop putting try-catch blocks in every controller action. Use the built-in UseExceptionHandler middleware.
app.UseExceptionHandler(errorApp => {
errorApp.Run(async context => {
context.Response.StatusCode = 500;
await context.Response.WriteAsJsonAsync(new { Message = "Server Error" });
});
});
