added JsonErrorFilter to automatically handle failing ajax calls.

This commit is contained in:
kay.one 2012-01-18 19:58:32 -08:00
commit b8ac694fc4
5 changed files with 73 additions and 38 deletions

View file

@ -0,0 +1,24 @@
using System.Linq;
using System.Web.Mvc;
using NzbDrone.Web.Models;
namespace NzbDrone.Web.Filters
{
public class JsonErrorFilter : FilterAttribute, IExceptionFilter
{
private readonly string _errorTitle;
public JsonErrorFilter(string errorTitle)
{
_errorTitle = errorTitle;
}
public void OnException(ExceptionContext filterContext)
{
filterContext.Result = NotificationResult.Error(_errorTitle, filterContext.Exception.Message);
filterContext.ExceptionHandled = true;
}
}
}