diff --git a/js/youtube-geofind-v4.js b/js/youtube-geofind-v4.js index 0e82641..132db9e 100644 --- a/js/youtube-geofind-v4.js +++ b/js/youtube-geofind-v4.js @@ -382,7 +382,7 @@ const geofind = (function() { }).fail(function(err) { elements[channel.id].progress.setBg("bg-danger"); - internal.displayMessage("alert-warning", JSON.stringify(err)); + internal.displayError("alert-warning", err); console.error(err); }) @@ -526,7 +526,7 @@ const geofind = (function() { elements.loadingDiv.fadeOut(defaults.animationMs); - internal.displayMessage("alert-warning", JSON.stringify(err)); + internal.displayError("alert-warning", err); console.error(err); }); @@ -606,6 +606,25 @@ const geofind = (function() { return request; }, + displayError: function (type, err) { + if (err.responseJSON + && err.responseJSON.error + && err.responseJSON.error.errors + && err.responseJSON.error.errors[0]) { + const error = err.responseJSON.error.errors[0]; + if (error.reason === "quotaExceeded") { + const html = "Quota Exceeded " + + "The daily API quota of 1,000,000 units has been reached for this application. " + + "This quota resets at midnight Pacific Time (PT) as per the Google Developers Console. " + + "See more detail here with issue #5."; + + this.displayMessage('alert-warning', html); + } else { + this.displayMessage('alert-warning', JSON.stringify(err)); + } + } + }, + displayMessage: function(type, message) { const html = "