fedimbed: mastoapi error handling
This commit is contained in:
parent
65efa56ee1
commit
e181188fa7
1 changed files with 16 additions and 6 deletions
|
@ -129,12 +129,15 @@ async function processUrl(msg, url) {
|
|||
}
|
||||
|
||||
if (redirUrl) {
|
||||
const postData2 = await fetch(url.replace("notice", "api/v1/statuses"), {
|
||||
headers: {
|
||||
"User-Agent": FRIENDLY_USERAGENT,
|
||||
},
|
||||
})
|
||||
.then((res) => res.json())
|
||||
const rawPostData2 = await fetch(
|
||||
url.replace("notice", "api/v1/statuses"),
|
||||
{
|
||||
headers: {
|
||||
"User-Agent": FRIENDLY_USERAGENT,
|
||||
},
|
||||
}
|
||||
)
|
||||
.then((res) => res.text())
|
||||
.catch((err) => {
|
||||
logger.error(
|
||||
"fedimbed",
|
||||
|
@ -142,6 +145,13 @@ async function processUrl(msg, url) {
|
|||
);
|
||||
});
|
||||
|
||||
let postData2;
|
||||
if (rawPostData2.startsWith("{")) {
|
||||
postData2 = JSON.parse(rawPostData2);
|
||||
} else {
|
||||
logger.warn("fedimbed", `Got non-JSON for "${url}" as MastoAPI: ${rawPostData2}`);
|
||||
}
|
||||
|
||||
if (!postData2) {
|
||||
logger.warn(
|
||||
"fedimbed",
|
||||
|
|
Loading…
Reference in a new issue