Based on this article I've implemented my own ExceptionFilterAttribute and registered the filter in GlobalConfiguration for custom exception handling in MVC 4 Web API.
However the ExceptionFilterAttribute only gets invoked for exceptions thrown in a controller action, after the request is resolved by the Framework.
I'd like to also implement custom error handling for exceptions thrown before a controller action is called. For example, an exception that is thrown in a DelegatingHandler currently returns me the following HTML:
<!DOCTYPE html>
<html>
<head>
<title>Exception of type 'System.Exception' was thrown.</title>
...
What do I need to do to return my own custom error for this scenario?