Improve error message on load error

This commit is contained in:
Paulo Gustavo Veiga 2021-12-25 12:09:02 -08:00
parent e0c18b9439
commit a3126f8532
2 changed files with 13 additions and 1 deletions

View File

@ -45,6 +45,9 @@ class LocalStorageManager extends PersistenceManager {
success(response) { success(response) {
xml = 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 I could not load it from a file, hard code one.
if (xml == null) { if (xml == null) {

View File

@ -108,6 +108,9 @@ class RESTPersistenceManager extends PersistenceManager {
async: false, async: false,
method: 'post', method: 'post',
headers: { 'Content-Type': 'application/json; charset=utf-8', Accept: 'application/json' }, 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', method: 'put',
headers: { 'Content-Type': 'text/plain' }, headers: { 'Content-Type': 'text/plain' },
data: 'false', 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) { success(responseText) {
xml = 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 I could not load it from a file, hard code one.
if (xml == null) { if (xml == null) {
throw new Error('Map could not be loaded'); throw new Error(`Map with id ${mapId} could not be loaded`);
} }
return xml; return xml;