diff --git a/src/common/api/rest-api.js b/src/common/api/rest-api.js index ecda441..4a837dc 100644 --- a/src/common/api/rest-api.js +++ b/src/common/api/rest-api.js @@ -23,14 +23,14 @@ import NotificationsFactory from "../data-managers/notifications-factory"; // Check if the error was due to network failure, timeouts, etc. // Can be used for the rest of requests -function isNetworkError(err) { +function isNetworkError(err, url) { let result = false; // If not status nor response fields, it is a network error. TODO: Handle timeouts if (err.status == null || err.status === 500 || err.response == null) { result = true; - let notification = err.timeout? NotificationsFactory.REQUEST_TIMEOUT : NotificationsFactory.SERVER_NOT_REACHABLE; + let notification = err.timeout? NotificationsFactory.REQUEST_TIMEOUT : NotificationsFactory.SERVER_NOT_REACHABLE(url); NotificationsDataManager.addNotification(notification); } return result; @@ -49,7 +49,7 @@ class RestAPI { req.end(function (error, res) { if (res == null || res.status !== 200) { - if (req.url !== prevURL) error.handled = isNetworkError(error); + if (req.url !== prevURL) error.handled = isNetworkError(error, url); prevURL = req.url; reject(error); } else { diff --git a/src/common/data-managers/notifications-factory.js b/src/common/data-managers/notifications-factory.js index 325815c..7b4867b 100644 --- a/src/common/data-managers/notifications-factory.js +++ b/src/common/data-managers/notifications-factory.js @@ -26,18 +26,18 @@ class NotificationsFactory { }; } - static get SERVER_NOT_REACHABLE() { + static SERVER_NOT_REACHABLE(url) { return { title: 'Server not reachable', - message: 'The server could not be reached. Please try again later.', + message: 'The url ' + url +' could not be reached. Please try again later.', level: 'error' }; } - static get REQUEST_TIMEOUT() { + static REQUEST_TIMEOUT(url) { return { title: 'Request timeout', - message: 'Request timed out. Please try again later.', + message: 'Request to ' + url + ' timed out. Please try again later.', level: 'error' }; }