title: How do I set up a global error handler in WebApi?
body: <p>I am building a .NET WebApi application and I would like to set up a global error handler (basically a function that executes when an exception bubbles up from anywhere in the application). <a href="http://aspnetwebstack.codeplex.com/workitem/1001" rel="noreferrer">this link</a> laments support for this, but several workarounds are offered. Unfortunately, I can't seem to find useful documentation for any of them.</p>
  
  <p>Here are my requirements:</p>
  
  <ul>
  <li>Catch exceptions hit in action methods as well as in other places (e. g. controller resolution).</li>
  <li>Have access to the original Exception object during my handling.</li>
  <li>Have access to services in my (Autofac) IOC container during the error handling process (this is a strong want but not a must have).</li>
  <li>No dependency on MVC (I am using pure WebApi). No dependency on IIS is highly desirable.</li>
  </ul>
  
  <p>How do I go about setting this up?</p>