Proper Error Handling for Ratelimits
Closed this issue · 3 comments
When getting ratelimited (I think (Actually is thrown when the daily request limit is reached)), there's just a thrown UnhandledPromiseRejectionWarning, nothing really useful.
(node:19824) UnhandledPromiseRejectionWarning: StatusCodeError: 404 - "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r\n<html xmlns=\"http://www.w
3.org/1999/xhtml\">\r\n <head>\r\n <title>Service</title>\r\n <style>BODY { color: #000000; background-color: white; font-family: Verdana; margin-left: 0px; margin-top: 0px; } #content { margin-left: 30px; font-size: .70em; padding-bottom: 2em; } A:link { color: #336699; font-weight: bold; text-decoration: underline; } A:visited { color: #6699cc; font-weight: bold; text-decoration: underline; } A:active { color: #336699; font-weight: bold; text-decoration: underline; } .heading1 { background-color: #003366; border-bottom: #336699 6px solid; color: #ffffff; font-family: Tahoma; font-size: 26px; font-weight: normal;margin: 0em 0em 10px -20px; padding-bottom: 8px; padding-left: 30px;padding-top: 16px;} pre { font-size:small; background-color: #e5e5cc; padding: 5px; font-family: Courier New; margin-top: 0px; border: 1px #f0f0e0 solid; white-space: pre-wrap; white-space: -pre-wrap; word-wrap: break-word; } table { border-collapse: collapse; border-spacing: 0px; font-family: Verdana;} table th { border-right: 2px white solid; border-bottom: 2px white solid; font-weight: bold; background-color: #cecf9c;} table td { border-right: 2px white solid; border-bottom: 2px white solid; background-color: #e5e5cc;}</style>\r\n </head>\r\n <body>\r\n <div id=\"content\">\r\n <p class=\"heading1\">Service</p>\r\n <p>Endpoint not found.</p>\r\n </div>\r\n </body>\r\n</html>"
I'd need to see the code because if I can recall, without looking at my notes, when you hit your daily limit it will throw a response with Daily request limit reached
or something of the sort in the ret_msg
, not a 404. I could be wrong.
However, it's just throwing a 404 for Endpoint not found.
I'd need to see the exact code and any parameters to try to recreate the issue locally. Is it working sometimes with the same setup and not others?
EDIT: Also, based on that error you're not handling any errors and if you go to node 15 or node 16 that warning will turn into an error and cause the process to exit with an error code. You should definitely wrap that in a try-catch or a promise, depending on your setup.
node 14 and below (maybe node 15, I usually stick with even nodes as they're LTS versions) will show a warning for those unhandled errors, it's been like that as long as I can remember. They were there as a warning for what's at least in node 16. I just encountered this the other day at work, an error wasn't caught and node 16 exited the process and node 14 just threw a warning.
Yea I was just about to say, that I forgot to catch the error and that should basically fix the issue. Sorry for the inconvenience
No problem at all! Happy to help when I can! Let me know if you have any issues with the library.