mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-30 00:08:42 +01:00
add try catch :p
This commit is contained in:
parent
3a0b5da64f
commit
cd1adeb62d
1 changed files with 13 additions and 10 deletions
|
@ -83,7 +83,6 @@ async function video(v) {
|
||||||
var comments = "";
|
var comments = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const urls = [
|
const urls = [
|
||||||
"invidious.sethforprivacy.com",
|
"invidious.sethforprivacy.com",
|
||||||
"invidious.weblibre.org",
|
"invidious.weblibre.org",
|
||||||
|
@ -94,6 +93,7 @@ async function video(v) {
|
||||||
|
|
||||||
let vid;
|
let vid;
|
||||||
|
|
||||||
|
try {
|
||||||
for (const url of urls) {
|
for (const url of urls) {
|
||||||
const videoInfo = await fetch(`https://${url}/api/v1/videos/${v}`).then(res => res.text());
|
const videoInfo = await fetch(`https://${url}/api/v1/videos/${v}`).then(res => res.text());
|
||||||
vid = await getJson(videoInfo);
|
vid = await getJson(videoInfo);
|
||||||
|
@ -105,9 +105,12 @@ for (const url of urls) {
|
||||||
|
|
||||||
if (!vid) {
|
if (!vid) {
|
||||||
// Handle error case
|
// Handle error case
|
||||||
|
throw new Error('Unable to fetch video information.');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
// Handle error case
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (checkUnexistingObject(vid)) {
|
if (checkUnexistingObject(vid)) {
|
||||||
var a;
|
var a;
|
||||||
|
|
Loading…
Reference in a new issue