Click or drag to resize
ErrorUnit.Attributes Namespace
The ErrorUnit.Attributes namespace contains classes for attaching filter attributes to MVC and Web API; recording the call to the respective controller in case of an error.
Classes
  ClassDescription
Public classCode exampleErrorUnitMvcActionFilterAttribute

To catch MVC Errors add to the FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters) method that is called by Global.asax.cs Application_Start method the code:

filters.Add(new ErrorUnit.Attributes.ErrorUnitActionFilterAttribute());
Examples
So the full code for the FilterConfig class in you App_Start folder should look like:
using System.Web;
using System.Web.Mvc;

public class FilterConfig
{
   public static void RegisterGlobalFilters(GlobalFilterCollection filters)
   {
       filters.Add(new ErrorUnit.Attributes.ErrorUnitMvcActionFilterAttribute());
       //anything else ...
   }
}
Public classCode exampleErrorUnitWebApiActionFilterAttribute

To catch Web API Errors add to GlobalConfiguration.Configure(WebApiConfig.Register) method that is called by Global.asax.cs Application_Start method the code:

config.Filters.Add(new ErrorUnit.Attributes.ErrorUnitWebApiActionFilterAttribute());
Examples
So the full code for the WebApiConfig class in you App_Start folder should look like:
using System.Web.Http;

public static class WebApiConfig
{
    public static void Register(HttpConfiguration config)
    {
        config.Filters.Add(new ErrorUnit.Attributes.ErrorUnitWebApiActionFilterAttribute());
        //Web API routes ...
    }
}