title: How can I use middleware with interceptor?
body: <p>The middleware is  sufficient for detecting exception request/response but not sufficient for all exception from start point of a process to endpoint. Forexample:</p>
  
  <pre class="lang-py prettyprint-override"><code>
      public class HttpStatusCodeExceptionMiddleware
      {
          private readonly RequestDelegate _next;
          private readonly ILogger&lt;HttpStatusCodeExceptionMiddleware&gt; _logger;
  
          public HttpStatusCodeExceptionMiddleware(RequestDelegate next, ILoggerFactory loggerFactory)
          {
              _next = next ?? throw new ArgumentNullException(nameof(next));
              _logger = loggerFactory?.CreateLogger&lt;HttpStatusCodeExceptionMiddleware&gt;() ?? throw new ArgumentNullException(nameof(loggerFactory));
          }
  
          public async Task Invoke(HttpContext context)
          {
              string message = "";
              try
              {
                  await _next.Invoke(context);
              }
             catch (LoginException ex)
              {
                  message = ex.Message;
  
                  StackTrace st = new StackTrace(true);
                  int num = 0;
                  var list = new List&lt;string&gt;();
                  for (int i = 0; i &lt; st.FrameCount; i++) // 4 frame var
  
                  {
  
                    ///....
                      list.Add(strBuilder.ToString());
  
                  }
  
                  if (!context.Response.HasStarted)
                  {
                      context.Response.ContentType = "application/json";
                      var response = new ExceptionModel(message);
                      // var json = JsonConvert.SerializeObject(response.getMessage());
  
                      var json = JsonConvert.SerializeObject(list);
                      await context.Response.WriteAsync(json);
                  }
              }
              catch (DivideByZeroException ex)
              {
                  message = ex.Message;
  
                  StackTrace st = new StackTrace(true);
  
  
                  int num = 0;
                  var list = new List&lt;string&gt;();
                  for (int i = 0; i &lt; st.FrameCount; i++) // 4 frame var
  
                  {
                      //.....
  
                      list.Add(strBuilder.ToString());
  
                  }
  
                  if (!context.Response.HasStarted)
                  {
                      context.Response.ContentType = "application/json";
                      var response = new ExceptionModel(message);
                      // var json = JsonConvert.SerializeObject(response.getMessage());
  
                      var json = JsonConvert.SerializeObject(list);
                      await context.Response.WriteAsync(json);
                  }
              }
          }
      }
  
  
  </code></pre>
  
  <pre class="lang-py prettyprint-override"><code>everything looks good but if I check error list as json . I can easly said that I can not see throwing error result. At the end and of the day I have to see
  all steps of throwing method. 
  
  [
    " Metod: Void MoveNext() File: C:\\Projects\\PlayGround\\Enrichment\\Enrichment\\WebAppEnrichment\\Extensions\\HttpStatusCodeExceptionMiddleware.cs Row: 39 Message 1 : Attempted to divide by zero.",
    " Metod: Void Start[TStateMachine](TStateMachine ByRef) File:  Row: 0 Message 2 : Attempted to divide by zero.",
    " Metod: System.Threading.Tasks.Task Invoke(Microsoft.AspNetCore.Http.HttpContext) File:  Row: 0 Message 3 : Attempted to divide by zero.",
    " Metod: System.Threading.Tasks.Task Invoke(Microsoft.AspNetCore.Http.HttpContext) File:  Row: 0 Message 4 : Attempted to divide by zero.",
    " Metod: Void MoveNext() File:  Row: 0 Message 5 : Attempted to divide by zero.",
    " Metod: Void Start[TStateMachine](TStateMachine ByRef) File:  Row: 0 Message 6 : Attempted to divide by zero.",
    " Metod: System.Threading.Tasks.Task Invoke(Microsoft.AspNetCore.Http.HttpContext) File:  Row: 0 Message 7 : Attempted to divide by zero.",
    " Metod: System.Threading.Tasks.Task Invoke(Microsoft.AspNetCore.Http.HttpContext) File:  Row: 0 Message 8 : Attempted to divide by zero.",
    " Metod: System.Threading.Tasks.Task Invoke(Microsoft.AspNetCore.Http.HttpContext) File:  Row: 0 Message 9 : Attempted to divide by zero.",
    " Metod: System.Threading.Tasks.Task ProcessRequestAsync(Context) File:  Row: 0 Message 10 : Attempted to divide by zero.",
    " Metod: Void MoveNext() File:  Row: 0 Message 11 : Attempted to divide by zero.",
    " Metod: Void Start[TStateMachine](TStateMachine ByRef) File:  Row: 0 Message 12 : Attempted to divide by zero.",
    " Metod: System.Threading.Tasks.Task`1[System.Boolean] ProcessRequestAsync() File:  Row: 0 Message 13 : Attempted to divide by zero.",
    " Metod: Void MoveNext() File:  Row: 0 Message 14 : Attempted to divide by zero.",
    " Metod: Void Start[TStateMachine](TStateMachine ByRef) File:  Row: 0 Message 15 : Attempted to divide by zero.",
    " Metod: System.Threading.Tasks.Task HandleRequest(Microsoft.AspNetCore.Server.IIS.Core.IISHttpContext) File:  Row: 0 Message 16 : Attempted to divide by zero.",
    " Metod: Void &lt;HandleRequest&gt;b__26_0(System.Object) File:  Row: 0 Message 17 : Attempted to divide by zero.",
    " Metod: Void RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) File:  Row: 0 Message 18 : Attempted to divide by zero.",
    " Metod: Boolean Dispatch() File:  Row: 0 Message 19 : Attempted to divide by zero."
  ]
  
  </code></pre>
  
  <p>HttpStatusCodeExceptionMiddleware.cs Row: 39 Message 1 : Attempted to divide by zero." is not a correct adress. Because it si thrown from last class. I have to see that :
   <a href="https://i.stack.imgur.com/6bpBW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6bpBW.png" alt="enter image description here"></a></p>
  
  <p>Don't worry about method names I am just trying.How can I return see real place happened error not last throtwing place. I created this result by using Microsoft unity interceptor. 
   How can I combine interceptor and middleware together for see deepest detail without writing try-catch shit.Thank you.</p>