title: Returning exceptions as JSON messages
body: <p>I am developing an API with ASP.NET Core and I am struggling with the exception handling.</p>
  <p>When any exception occurs, or in any controller where I want to return custom errors with different status codes,  I want to return JSON-formatted exception reports. I do not need HTML in the error response.</p>
  <p>I'm not sure if I should use middleware for this, or something else. How should I return JSON exceptions in an ASP.NET Core API?</p>