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

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

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

@ -13,6 +13,7 @@ using NzbDrone.Core.Model;
using NzbDrone.Core.Providers; using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository; using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality; using NzbDrone.Core.Repository.Quality;
using NzbDrone.Web.Filters;
using NzbDrone.Web.Models; using NzbDrone.Web.Models;
namespace NzbDrone.Web.Controllers namespace NzbDrone.Web.Controllers
@ -94,10 +95,9 @@ namespace NzbDrone.Web.Controllers
return new EmptyResult(); return new EmptyResult();
} }
[JsonErrorFilter]
public JsonResult LocalSearch(string term) public JsonResult LocalSearch(string term)
{ {
//Get Results from the local DB and return
var results = _seriesProvider.SearchForSeries(term).Select(s => new SeriesSearchResultModel var results = _seriesProvider.SearchForSeries(term).Select(s => new SeriesSearchResultModel
{ {
Id = s.SeriesId, 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) if (this.url.indexOf("/notification/Comet") === 0 || this.url.indexOf("/Health/Index") === 0 || this.url.indexOf("/signalr") === 0)
return; return;
alert("Status: " + textStatus + ", Error: " + thrownError);
$.gritter.add({ $.gritter.add({
title: 'Request failed', title: 'Request failed',
text: this.url, text: 'Url: ' + this.url + '<br/>Error: ' + thrownError,
image: '../../content/images/error.png', image: '../../content/images/error.png',
class_name: 'gritter-fail', class_name: 'gritter-fail',
time: 10000 time: 10000

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

@ -40,18 +40,11 @@ function sendToServer(id) {
type: "POST", type: "POST",
url: deleteQualityProfileUrl, url: deleteQualityProfileUrl,
data: jQuery.param({ profileId: id }), 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) { success: function (data, textStatus, jqXHR) {
if (data == "ok") { if (data == "ok") {
$("#profile_" + id).remove(); $("#profile_" + id).remove();
removeOption(id); removeOption(id);
} }
else {
alert(data);
}
} }
}); });
} }

@ -111,9 +111,6 @@ function saveSeasonIgnore(seasonNumber, ignored) {
type: "POST", type: "POST",
url: saveSeasonIgnoreUrl, url: saveSeasonIgnoreUrl,
data: jQuery.param({ seriesId: seriesId, seasonNumber: seasonNumber, ignored: ignored }), 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", type: "POST",
url: saveEpisodeIgnoreUrl, url: saveEpisodeIgnoreUrl,
data: jQuery.param({ episodeId: episodeId, ignored: ignored }), 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