mirror of
https://github.com/9001/copyparty.git
synced 2025-11-24 07:23:22 -07:00
better error handling
This commit is contained in:
parent
9b0c14ddf6
commit
885a5a14f4
|
|
@ -202,6 +202,21 @@ window.baguetteBox = (function () {
|
|||
prepareOverlay(gallery, userOptions);
|
||||
console.log("prepare done, starting show")
|
||||
showOverlay(0);
|
||||
}
|
||||
).catch((reason) => {
|
||||
console.error("cbz-ded", reason);
|
||||
var t;
|
||||
try {
|
||||
t = uricom_dec(cbzElement.href.split('/').pop());
|
||||
} catch (ex) {
|
||||
}
|
||||
|
||||
var msg = "Could not browse " + (t ? t : 'archive');
|
||||
try {
|
||||
msg += "\n\n" + reason.message;
|
||||
|
||||
} catch (ex) {}
|
||||
toast.err(20, msg, 'cbz-ded');
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -213,10 +228,16 @@ window.baguetteBox = (function () {
|
|||
if (gallery.length !== 0) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
var href = cbzElement.href
|
||||
var href = cbzElement.href;
|
||||
var zlsHref = href + (href.indexOf("?") === -1 ? "?" : "&") + "zls";
|
||||
console.log("pre-fetch")
|
||||
return fetch(zlsHref).then(response => response.json())
|
||||
return fetch(zlsHref)
|
||||
.then(response => {
|
||||
if (response.ok) {
|
||||
return response.json();
|
||||
} else {
|
||||
throw new Error("Archive is invalid");
|
||||
}
|
||||
})
|
||||
.then((fileList) => {
|
||||
console.log("fetched")
|
||||
var imagesList = fileList.filter((name) =>
|
||||
|
|
@ -224,6 +245,10 @@ window.baguetteBox = (function () {
|
|||
&& cbz_pics.indexOf(name.split(".").pop()) !== -1
|
||||
).sort();
|
||||
|
||||
if (imagesList.length === 0) {
|
||||
throw new Error("Archive does not contain any images");
|
||||
}
|
||||
|
||||
imagesList.forEach((imageName, index) => {
|
||||
var imageHref = href
|
||||
+ (href.indexOf("?") === -1 ? "?" : "&")
|
||||
|
|
@ -237,7 +262,6 @@ window.baguetteBox = (function () {
|
|||
};
|
||||
gallery.push(galleryItem);
|
||||
});
|
||||
console.log(gallery);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue