We could manage exceptions globally by creating an Exception middleware.
Since Web API 2.1, we use IExceptionHandler to handle exceptions globally. It helps catch exceptions in controllers, actions, filters, routes, and sometimes, MessageHandlers and MediaTypeFormatters.
We can also think about creating a custom global Exception filter to log the exception, but we will talk about that in Chapter 12, Filters.