fedimbed: try with if instead of catch
This commit is contained in:
parent
3ee873082c
commit
2aa5adc1ed
1 changed files with 29 additions and 25 deletions
|
@ -128,16 +128,18 @@ async function processUrl(msg, url, spoiler = false) {
|
||||||
"fedimbed",
|
"fedimbed",
|
||||||
`Failed to signed fetch "${url}", retrying unsigned: ${err}`
|
`Failed to signed fetch "${url}", retrying unsigned: ${err}`
|
||||||
);
|
);
|
||||||
rawPostData = await fetch(url, {
|
}
|
||||||
headers: {
|
if (!rawPostData) {
|
||||||
"User-Agent": FRIENDLY_USERAGENT,
|
try {
|
||||||
Accept: "application/activity+json",
|
rawPostData = await fetch(url, {
|
||||||
},
|
headers: {
|
||||||
})
|
"User-Agent": FRIENDLY_USERAGENT,
|
||||||
.then((res) => res.text())
|
Accept: "application/activity+json",
|
||||||
.catch((err) => {
|
},
|
||||||
logger.error("fedimbed", `Failed to fetch "${url}": ${err}`);
|
}).then((res) => res.text());
|
||||||
});
|
} catch (err) {
|
||||||
|
logger.error("fedimbed", `Failed to fetch "${url}": ${err}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let postData;
|
let postData;
|
||||||
|
@ -223,21 +225,23 @@ async function processUrl(msg, url, spoiler = false) {
|
||||||
"fedimbed",
|
"fedimbed",
|
||||||
`Failed to signed fetch "${url}" via MastoAPI, retrying unsigned: ${err}`
|
`Failed to signed fetch "${url}" via MastoAPI, retrying unsigned: ${err}`
|
||||||
);
|
);
|
||||||
rawPostData2 = await signedFetch(
|
}
|
||||||
redirUrl,
|
if (!rawPostData2) {
|
||||||
Object.assign(options, {
|
try {
|
||||||
headers: Object.assign(headers, {
|
rawPostData2 = await signedFetch(
|
||||||
"User-Agent": FRIENDLY_USERAGENT,
|
redirUrl,
|
||||||
}),
|
Object.assign(options, {
|
||||||
})
|
headers: Object.assign(headers, {
|
||||||
)
|
"User-Agent": FRIENDLY_USERAGENT,
|
||||||
.then((res) => res.text())
|
}),
|
||||||
.catch((err) => {
|
})
|
||||||
logger.error(
|
).then((res) => res.text());
|
||||||
"fedimbed",
|
} catch (err) {
|
||||||
`Failed to fetch "${url}" via MastoAPI: ${err}`
|
logger.error(
|
||||||
);
|
"fedimbed",
|
||||||
});
|
`Failed to fetch "${url}" via MastoAPI: ${err}`
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let postData2;
|
let postData2;
|
||||||
|
|
Loading…
Reference in a new issue