2021-05-30

How could I fs.unlink() a file that caused the error?

So, I'm working with files that all send POST requests to different URLs. However, if a POST request receives a 404 response it will error the entire network instead of just that file. Is there a way I would be able to fs.unlink() the file that caused the error?

If not, is there another solution to this? As I don't want the entire server network to go offline just because of a 404 error on just one of the POST requests.

onShoutEvent.on('data', async shout => {
    let embed = embedMaker(`New Shout!`, `\n"${shout.body}"`);
    embed.setAuthor(`${shout.poster.username}`);
    embed.setThumbnail(`http://www.roblox.com/Thumbs/Avatar.ashx?x=150&y=150&Format=Png&username=${shout.poster.username}`);
    embed.setURL(`https://www.roblox.com/groups/${group}`)
    embed.setFooter(`${customFooter}`)
    WebHookClient.send(embed);
    saveData(shout.body);
});

It will check for new "shouts" and will send a request to that Webhook by POST, however if the Webhook is deleted it'll throw a 404 error thus erroring all other code that is being run in the directory.



from Recent Questions - Stack Overflow https://ift.tt/2SIRuKE
https://ift.tt/eA8V8J

No comments:

Post a Comment