diff --git a/js/node_helper.js b/js/node_helper.js index 3ecca4ce..45bd03dd 100644 --- a/js/node_helper.js +++ b/js/node_helper.js @@ -126,6 +126,8 @@ NodeHelper.checkFetchError = function (error) { let error_type = "MODULE_ERROR_UNSPECIFIED"; if (error.code === "EAI_AGAIN") { error_type = "MODULE_ERROR_NO_CONNECTION"; + } else if (error.message === "Unauthorized") { + error_type = "MODULE_ERROR_UNAUTHORIZED"; } return error_type; }; diff --git a/modules/default/calendar/calendar.js b/modules/default/calendar/calendar.js index 1b356ac4..40e43ad2 100755 --- a/modules/default/calendar/calendar.js +++ b/modules/default/calendar/calendar.js @@ -147,7 +147,8 @@ Module.register("calendar", { } } } else if (notification === "CALENDAR_ERROR") { - this.error = this.translate("MODULE_CONFIG_ERROR", { MODULE_NAME: this.name, ERROR: payload.error }); + let error_message = this.translate(payload.error_type); + this.error = this.translate("MODULE_CONFIG_ERROR", { MODULE_NAME: this.name, ERROR: error_message }); this.loaded = true; } diff --git a/modules/default/calendar/node_helper.js b/modules/default/calendar/node_helper.js index c74b165e..5b1a8bad 100644 --- a/modules/default/calendar/node_helper.js +++ b/modules/default/calendar/node_helper.js @@ -58,6 +58,7 @@ module.exports = NodeHelper.create({ Log.error("Calendar Error. Could not fetch calendar: ", fetcher.url(), error); let error_type = NodeHelper.checkFetchError(error); this.sendSocketNotification("CALENDAR_ERROR", { + id: identifier, error_type }); }); diff --git a/tests/e2e/modules/calendar_spec.js b/tests/e2e/modules/calendar_spec.js index edecf4fa..097ce220 100644 --- a/tests/e2e/modules/calendar_spec.js +++ b/tests/e2e/modules/calendar_spec.js @@ -150,7 +150,7 @@ describe("Calendar module", function () { }); it("should show Unauthorized error", function () { - return app.client.waitUntilTextExists(".calendar", "Error in the calendar module. Unauthorized", 10000); + return app.client.waitUntilTextExists(".calendar", "Error in the calendar module. Authorization failed", 10000); }); }); }); diff --git a/translations/en.json b/translations/en.json index 82748e6b..5959fc82 100644 --- a/translations/en.json +++ b/translations/en.json @@ -32,6 +32,7 @@ "MODULE_CONFIG_ERROR": "Error in the {MODULE_NAME} module. {ERROR}", "MODULE_ERROR_MALFORMED_URL": "Malformed url.", "MODULE_ERROR_NO_CONNECTION": "No internet connection.", + "MODULE_ERROR_UNAUTHORIZED": "Authorization failed.", "MODULE_ERROR_UNSPECIFIED": "Check logs for more details.", "UPDATE_NOTIFICATION": "MagicMirror² update available.",