livgust / covid-vaccine-scrapers

Open-source project using Nodejs and Puppeteer to scrape websites for COVID vaccine availability in Massachusetts. Can be modified to suit other areas and needs.
MIT License
66 stars 33 forks source link

catching error inside async function #245

Closed harcod closed 3 years ago

harcod commented 3 years ago

https://javascript.info/try-catch#rethrowing

See the final example in this section that starts with:

The error throwing on line (*) from inside catch block “falls out” of try...catch and can be either caught by an outer try...catch construct (if it exists), or it kills the script.

So the catch block actually handles only errors that it knows how to deal with and “skips” all others.

harcod commented 3 years ago

This might also lend some insight... https://www.telerik.com/blogs/what-is-json-how-to-handle-unexpected-token-error

harcod commented 3 years ago

New version uses reject.
Are there more scrapers with this problem?