InvokeActionWithExceptionFilters (which is always called, even when an exception is not registered) always does the equivalent of the following when no exception filter handles an exception:
Exception e = null;
try
{
// execute controller pipeline
return;
}
catch (Exception ex)
{
e = ex;
}
var response = filters.Handle(e);
if (response != null)
return response;
else
throw e;
That means we always lose the original stack. I've noticed this in debugging. Instead, it should do this:
Exception e = null;
try
{
// execute controller pipeline
return;
}
catch (Exception ex)
{
var response = filters.Handle(ex);
if (response != null)
return response;
else
throw;
}
(We still need to preserve the ability for exception filters to change/wrap the exception, so that will require something like the existing code, but if the exception isn't changed, we should throw; rather than throw ex;)
Exception e = null;
try
{
// execute controller pipeline
return;
}
catch (Exception ex)
{
e = ex;
}
var response = filters.Handle(e);
if (response != null)
return response;
else
throw e;
That means we always lose the original stack. I've noticed this in debugging. Instead, it should do this:
Exception e = null;
try
{
// execute controller pipeline
return;
}
catch (Exception ex)
{
var response = filters.Handle(ex);
if (response != null)
return response;
else
throw;
}
(We still need to preserve the ability for exception filters to change/wrap the exception, so that will require something like the existing code, but if the exception isn't changed, we should throw; rather than throw ex;)