From a3126f85320c325aae6cb507fd5b76ba653c9124 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Sat, 25 Dec 2021 12:09:02 -0800 Subject: [PATCH] Improve error message on load error --- .../mindplot/src/components/LocalStorageManager.js | 3 +++ .../mindplot/src/components/RestPersistenceManager.js | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/mindplot/src/components/LocalStorageManager.js b/packages/mindplot/src/components/LocalStorageManager.js index 9b1f4b59..46dc8211 100644 --- a/packages/mindplot/src/components/LocalStorageManager.js +++ b/packages/mindplot/src/components/LocalStorageManager.js @@ -45,6 +45,9 @@ class LocalStorageManager extends PersistenceManager { success(response) { xml = response; }, + error(xhr, ajaxOptions, thrownError) { + console.error(`Request error => status:${xhr.status} ,thrownError: ${thrownError}`); + }, }); // If I could not load it from a file, hard code one. if (xml == null) { diff --git a/packages/mindplot/src/components/RestPersistenceManager.js b/packages/mindplot/src/components/RestPersistenceManager.js index a912369a..4e743079 100644 --- a/packages/mindplot/src/components/RestPersistenceManager.js +++ b/packages/mindplot/src/components/RestPersistenceManager.js @@ -108,6 +108,9 @@ class RESTPersistenceManager extends PersistenceManager { async: false, method: 'post', headers: { 'Content-Type': 'application/json; charset=utf-8', Accept: 'application/json' }, + error(xhr, ajaxOptions, thrownError) { + console.error(`Request error => status:${xhr.status} ,thrownError: ${thrownError}`); + }, }); } @@ -119,6 +122,9 @@ class RESTPersistenceManager extends PersistenceManager { method: 'put', headers: { 'Content-Type': 'text/plain' }, data: 'false', + error(xhr, ajaxOptions, thrownError) { + console.error(`Request error => status:${xhr.status} ,thrownError: ${thrownError}`); + }, }); } @@ -147,11 +153,14 @@ class RESTPersistenceManager extends PersistenceManager { success(responseText) { xml = responseText; }, + error(xhr, ajaxOptions, thrownError) { + console.error(`Request error => status:${xhr.status} ,thrownError: ${thrownError}`); + }, }); // If I could not load it from a file, hard code one. if (xml == null) { - throw new Error('Map could not be loaded'); + throw new Error(`Map with id ${mapId} could not be loaded`); } return xml;