I am using a global ErrorHandler filter to log unhandled exceptions, but I would also like to be able to use this same handler to log handled exceptions from within a catch block.
I would like to access the global filters and execute the ErrorHandler as configured, but I'm having some difficulty doing this. I tried the following, but Resharper is telling me that the filter can't ever be my ErrorLogFilter.
foreach (var filter in GlobalFilters.Filters)
{
    if (filter is ErrorLogFilter) // Static analysis tells me this can never be an ErrorLogFilter
    {
        // want to execute the filter
    }
}
ErrorLogFilter is added to the global filters like this:
GlobalFilters.Filters.Add(new ErrorLogFilter(provider));
ErrorLogFilter (as part of Elfar, similar to Elmah, but for MVC) is defined as:
public class ErrorLogFilter : FilterAttribute, IExceptionFilter
Any suggestions on how to accomplish this?
 
                        
GlobalFilters.Filtersis a GlobalFilterCollection which contains Filter's which are wrappers around the addedIMvcFilters.Try this instead:
So Reshaper is correct signaled that there is no
ErrorLogFilterinGlobalFilters.Filters.