mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-14 18:57:39 -07:00
added JsonErrorFilter to automatically handle failing ajax calls.
This commit is contained in:
parent
7c6d745c86
commit
b8ac694fc4
5 changed files with 73 additions and 38 deletions
24
NzbDrone.Web/Filters/JsonErrorFilter.cs
Normal file
24
NzbDrone.Web/Filters/JsonErrorFilter.cs
Normal 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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue