1
0
Fork 0
mirror of https://codeberg.org/ashley/poke.git synced 2024-11-17 07:14:40 -05:00

add try catch :p

This commit is contained in:
Ashley 2023-03-11 16:03:14 +00:00
parent 399b01ac60
commit 4a2d836cda

View file

@ -86,7 +86,8 @@ async function video(v) {
); );
var comments = await getJson(inv_comments); var comments = await getJson(inv_comments);
} catch { } catch (error) {
console.error("Error getting comments", error);
var comments = ""; var comments = "";
} }
@ -96,7 +97,7 @@ async function video(v) {
const videoInfo = await fetch(`${config.invapi}/videos/${v}`).then(res => res.text()); const videoInfo = await fetch(`${config.invapi}/videos/${v}`).then(res => res.text());
vid = await getJson(videoInfo); vid = await getJson(videoInfo);
} catch (error) { } catch (error) {
console.error("Error getting video info", error);
} }
@ -113,7 +114,8 @@ async function video(v) {
) )
.then((res) => res.text()) .then((res) => res.text())
.then((xml) => getJson(toJson(xml))); .then((xml) => getJson(toJson(xml)));
} catch { } catch (error) {
console.error("Error getting channel info", error);
var a = ""; var a = "";
} }
@ -128,11 +130,15 @@ async function video(v) {
const data = await fetcher(v); const data = await fetcher(v);
const nightlyJsonData = getJson(nightlyRes); const nightlyJsonData = getJson(nightlyRes);
try {
const video = await fetch(`${config.tubeApi}video?v=${v}`) const video = await fetch(`${config.tubeApi}video?v=${v}`)
.then((res) => res.text()) .then((res) => res.text())
.then((xml) => getJson(toJson(xml))) .then((xml) => getJson(toJson(xml)))
.catch(" ") .catch(error => {
console.error("Error getting video", error);
return " ";
});
// Store result in cache // Store result in cache
cache[v] = { cache[v] = {
@ -155,6 +161,9 @@ async function video(v) {
}; };
return cache[v].result; return cache[v].result;
} catch (error) {
console.error("Error getting video", error);
}
} }
} }