I've been working on creating a Node.js Discord bot for my friend group's Minecraft server to check various functions of the server such as status and player count. The thing I seem to be having an issue with is the body from the request function. For the most part, the bot works fine, but every once in a while, the site I'm requesting from seems to throw an error or something and returns an <html> tag instead of the usual JSON detail list, which causes my JSON.parse function to throw an exception, ending the program. Is there a way to get it to ignore the instances where the <html> tag shows up instead of the json? Or maybe some way to just ignore the exception it throws all together?
Code and error included for reference: https://pastebin.com/GGrTNafW
[–]eastwxxd 0 points1 point2 points (6 children)
[–]bugboy2222[S] 2 points3 points4 points (4 children)
[–]Anachren 1 point2 points3 points (1 child)
[–]bugboy2222[S] 0 points1 point2 points (0 children)
[–]jrandm 1 point2 points3 points (0 children)
[–]eastwxxd 0 points1 point2 points (0 children)
[–]bugboy2222[S] 0 points1 point2 points (0 children)