Brutal error handling...
This commit is contained in:
parent
76a307ae8b
commit
2baef1a07e
19
js/ds.js
19
js/ds.js
@ -89,11 +89,13 @@ DataSpace.createObjectShape = function(resource) {
|
|||||||
*/
|
*/
|
||||||
DataSpace.fetchReport = async function(uuid, format='json')
|
DataSpace.fetchReport = async function(uuid, format='json')
|
||||||
{
|
{
|
||||||
// TODO Errors!!
|
|
||||||
const jsonRep =
|
const jsonRep =
|
||||||
await fetch(`${this.BASE_URL}${this.RES_ENDPOINT}${uuid}?format=${format}&indent=2`)
|
await fetch(`${this.BASE_URL}${this.RES_ENDPOINT}${uuid}?format=${format}&indent=2`)
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.catch();
|
.catch(excep => {
|
||||||
|
_createError(excep, 'error')
|
||||||
|
document.querySelector('.modal').classList.remove('active');
|
||||||
|
});
|
||||||
|
|
||||||
return jsonRep;
|
return jsonRep;
|
||||||
}
|
}
|
||||||
@ -161,6 +163,19 @@ DataSpace.getImagesSrc = function(resource) {
|
|||||||
return fileNames;
|
return fileNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _createError(message, htmlId)
|
||||||
|
{
|
||||||
|
const error = document.createElement('div');
|
||||||
|
const clear = document.createElement('button');
|
||||||
|
error.className = 'toast toast-error';
|
||||||
|
clear.className = 'btn btn-clear float-right';
|
||||||
|
|
||||||
|
error.appendChild(clear);
|
||||||
|
error.textContent = message;
|
||||||
|
|
||||||
|
document.querySelector(`#${htmlId}`).appendChild(error);
|
||||||
|
}
|
||||||
|
|
||||||
export default DataSpace;
|
export default DataSpace;
|
||||||
/**
|
/**
|
||||||
* Fetch file blob (CORS...)
|
* Fetch file blob (CORS...)
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
</header>
|
</header>
|
||||||
<main>
|
<main>
|
||||||
<div class="report-container">
|
<div class="report-container">
|
||||||
|
<div id="error"></div>
|
||||||
<h2 class="mt-1 p-2" id="rep-tit"></h2>
|
<h2 class="mt-1 p-2" id="rep-tit"></h2>
|
||||||
<div class="columns">
|
<div class="columns">
|
||||||
<div class="column col-7">
|
<div class="column col-7">
|
||||||
|
Loading…
Reference in New Issue
Block a user