title: How to get correct stack trace for exceptions in Web API 2 async actions?
body: <p>I have a simple API controller method</p>
  
  <pre><code>public async Task&lt;Models.Timesheet&gt; GetByDate(DateTime date, string user = null)
  {
      throw new InvalidOperationException();
  }
  </code></pre>
  
  <p>Now the problem is that the exception stack trace I get either in my custom action filter or just by setting <code>IncludeErrorDetailPolicy.Always</code> is like this</p>
  
  <pre><code>System.InvalidOperationException: Operation is not valid due to the current state of the object.
     at System.Web.Http.Filters.ActionFilterAttribute.&lt;CallOnActionExecutedAsync&gt;d__1.MoveNext()
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
     at System.Web.Http.Controllers.ActionFilterResult.&lt;ExecuteAsync&gt;d__2.MoveNext()
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at System.Web.Http.ApiController.&lt;InvokeActionWithExceptionFilters&gt;d__1.MoveNext()
  </code></pre>
  
  <p>It used to be much better with Web API v1. After upgrade to v2 the stack traces are pretty much unusable - it is expected that with async/await the stack traces will not be as they once used to be but in this case the whole stack trace does not include any hint at even the class that failed. Is there something that can be configured in Web API to mitigate the issue?</p>