title: Can Anyone Explain the work flow of IExceptionHandler with Sample Client Application
body: <p>I am facing below issues in this Sample:</p>
  
  <p>I am not able to find <code>IsOutermostCatchBlock</code> in <code>ExceptionContext</code></p>
  
  <p>If Exception occurs, this <code>HandleAsync</code> method is executing twice.</p>
  
  <p>(<a href="http://www.asp.net/web-api/overview/web-api-routing-and-actions/web-api-global-error-handling">http://www.asp.net/web-api/overview/web-api-routing-and-actions/web-api-global-error-handling</a>)</p>
  
  <pre><code>public class CustomExceptionHandler : IExceptionHandler
  {
      public virtual Task HandleAsync(ExceptionHandlerContext context,
                                          CancellationToken cancellationToken)
      {
          if (!ShouldHandle(context))
          {
              return Task.FromResult(0);
          }
  
              return HandleAsyncCore(context, cancellationToken);
          }
  
          public virtual Task HandleAsyncCore(ExceptionHandlerContext context,
                                              CancellationToken cancellationToken)
          {
              HandleCore(context);
              return Task.FromResult(0);
          }
  
          public virtual void HandleCore(ExceptionHandlerContext context)
          {
          }
  
          public virtual bool ShouldHandle(ExceptionHandlerContext context)
          {    
               return context.ExceptionContext.IsOutermostCatchBlock;
          }
  
      }
  
      public class OopsExceptionHandler : CustomExceptionHandler
      {
          public override void HandleCore(ExceptionHandlerContext context)
          {
              context.Result = new TextPlainErrorResult
              {
                  Request = context.ExceptionContext.Request,
                  Content = "Oops! Sorry! Something went wrong." +
                            "Please contact support@contoso.com so we can try to fix it."
              };
          }
  
          private class TextPlainErrorResult : IHttpActionResult
          {
              public HttpRequestMessage Request { get; set; }
              public string Content { get; set; }
  
              public Task&lt;HttpResponseMessage&gt; ExecuteAsync(CancellationToken cancellationToken)
              {
                  HttpResponseMessage response =
                                   new HttpResponseMessage(HttpStatusCode.InternalServerError);
                  response.Content = new StringContent(Content);
                  response.RequestMessage = Request;
                  return Task.FromResult(response);
              }
          }
      }
  }
  </code></pre>