Better client side error handling

This commit is contained in:
Mark McDowall 2012-09-30 17:05:16 -07:00
parent 08d811f7c3
commit 02cf23721a
8 changed files with 12 additions and 20 deletions

View file

@ -110,6 +110,7 @@ namespace NzbDrone.Web.Controllers
}
[HttpPost]
[JsonErrorFilter]
public JsonResult AddNewSeries(string path, string seriesName, int seriesId, int qualityProfileId, string startDate)
{
if (string.IsNullOrWhiteSpace(path) || String.Equals(path,"null",StringComparison.InvariantCultureIgnoreCase))
@ -143,6 +144,7 @@ namespace NzbDrone.Web.Controllers
}
[HttpGet]
[JsonErrorFilter]
public JsonResult LookupSeries(string term)
{
try

View file

@ -133,6 +133,7 @@ namespace NzbDrone.Web.Controllers
}
[HttpPost]
[JsonErrorFilter]
public EmptyResult SaveSeasonIgnore(int seriesId, int seasonNumber, bool ignored)
{
_seasonProvider.SetIgnore(seriesId, seasonNumber, ignored);
@ -140,6 +141,7 @@ namespace NzbDrone.Web.Controllers
}
[HttpPost]
[JsonErrorFilter]
public EmptyResult SaveEpisodeIgnore(int episodeId, bool ignored)
{
_episodeProvider.SetEpisodeIgnore(episodeId, ignored);

View file

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Web.Mvc;
using NzbDrone.Common;
using NzbDrone.Web.Filters;
namespace NzbDrone.Web.Controllers
{
@ -27,6 +28,7 @@ namespace NzbDrone.Web.Controllers
}
[HttpGet]
[JsonErrorFilter]
public JsonResult GetDirectories(string term)
{
IEnumerable<string> dirs = null;
@ -38,7 +40,6 @@ namespace NzbDrone.Web.Controllers
if (windowsSep > -1)
{
dirs = _diskProvider.GetDirectories(term.Substring(0, windowsSep + 1));
}
//Unix
@ -55,6 +56,9 @@ namespace NzbDrone.Web.Controllers
//Swallow the exceptions so proper JSON is returned to the client (Empty results)
}
if (dirs == null)
throw new Exception("A valid path was not provided");
return Json(dirs, JsonRequestBehavior.AllowGet);
}
}

View file

@ -13,6 +13,7 @@ using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Web.Filters;
using NzbDrone.Web.Models;
namespace NzbDrone.Web.Controllers
@ -94,10 +95,9 @@ namespace NzbDrone.Web.Controllers
return new EmptyResult();
}
[JsonErrorFilter]
public JsonResult LocalSearch(string term)
{
//Get Results from the local DB and return
var results = _seriesProvider.SearchForSeries(term).Select(s => new SeriesSearchResultModel
{
Id = s.SeriesId,