judgelord / regulationsdotgov

a package to get data from regulations.gov
https://judgelord.github.io/regulationsdotgov/
MIT License
0 stars 0 forks source link

error handling for bad API results #3

Open judgelord opened 3 months ago

judgelord commented 3 months ago

We need error handling to deal with bad API results and one bad call that causes an error that voids a long-running loop from returning good results.

get_commentdetails4() is currently written as one function that includes both the API calls and extracting the data from JSON format. These should be split into two helper functions so that if there are errors, we don't need to go back and hit the API for everything. We can store the API results and include an option to return the raw results as a list in addition to the data frame.

For now, I am using possibly() with a random result ("content_init"), replacing rows in the data frame where the result cannot be extracted from JSON.

I think we should replace this with a filter that omits bad API results before attempting to extract content from them.