Better client side error handling

pull/6/head
Mark McDowall 12 years ago
parent 08d811f7c3
commit 02cf23721a

@ -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

@ -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);

@ -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);
}
}

@ -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,

@ -37,10 +37,9 @@
if (this.url.indexOf("/notification/Comet") === 0 || this.url.indexOf("/Health/Index") === 0 || this.url.indexOf("/signalr") === 0)
return;
alert("Status: " + textStatus + ", Error: " + thrownError);
$.gritter.add({
title: 'Request failed',
text: this.url,
text: 'Url: ' + this.url + '<br/>Error: ' + thrownError,
image: '../../content/images/error.png',
class_name: 'gritter-fail',
time: 10000

@ -46,7 +46,6 @@ $(".addExistingButton").live('click', function () {
data: jQuery.param({ path: path, seriesName: title, seriesId: seriesId, qualityProfileId: qualityId, startDate: date }),
error: function (req, status, error) {
$(button).removeAttr('disabled');
alert("Sorry! We could not add " + path + " at this time. " + error);
},
success: function() {
root.hide('highlight', 'fast');
@ -137,7 +136,6 @@ $('#saveNewSeries').live('click', function () {
data: jQuery.param({ path: path, seriesName: seriesTitle, seriesId: seriesId, qualityProfileId: qualityId, startDate: date }),
error: function (req, status, error) {
$('#saveNewSeries').removeAttr('disabled');
alert("Sorry! We could not add " + path + " at this time. " + error);
},
success: function () {
$('#saveNewSeries').removeAttr('disabled');

@ -40,18 +40,11 @@ function sendToServer(id) {
type: "POST",
url: deleteQualityProfileUrl,
data: jQuery.param({ profileId: id }),
error: function (req, status, error) {
alert("Sorry! We could not delete your Profile at this time. " + error);
},
success: function (data, textStatus, jqXHR) {
if (data == "ok") {
$("#profile_" + id).remove();
removeOption(id);
}
else {
alert(data);
}
}
});
}

@ -111,9 +111,6 @@ function saveSeasonIgnore(seasonNumber, ignored) {
type: "POST",
url: saveSeasonIgnoreUrl,
data: jQuery.param({ seriesId: seriesId, seasonNumber: seasonNumber, ignored: ignored }),
error: function (req, status, error) {
alert("Sorry! We could save the ignore settings for Series: " + seriesId + ", Season: " + seasonNumber + " at this time. " + error);
}
});
}
@ -122,9 +119,6 @@ function saveEpisodeIgnore(episodeId, ignored) {
type: "POST",
url: saveEpisodeIgnoreUrl,
data: jQuery.param({ episodeId: episodeId, ignored: ignored }),
error: function (req, status, error) {
alert("Sorry! We could save the ignore settings for Episode: " + episodeId + " at this time. " + error);
}
});
}

Loading…
Cancel
Save