-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update get_eurostat_json.R #262
Conversation
It seems that the problem described in #260 is now solved. Great. However, I couldn't use examples mentioned there to debug this new code. Boo. I could do something by providing a wrong parameter to the API. E.g. this erroneous query (it uses fromTimePeriod instead of the correct sinceTimePeriod):
Procudes this url: https://ec.europa.eu/eurostat/api/dissemination/statistics/1.0/data/TIPSHO40?fromTimePeriod=2020&untilTimePeriod=2021&format=JSON&lang=EN
When I do the query in R, I get the following output:
So it actually gets the HTTP status correctly in the old code ("Request failed [400]") but it prints a wrong message after it ("Client Error - 100 No results found"). Could you fix the code contribution so that
|
Reading error message (http status, id and label) from the response and return the status, id and label that were saved in the memory.
Solved! Feel free to comment! |
Thanks, it works quite nicely now:
Maybe it would be nice to add error message and error id labels in writing as well? Such as 400 Bad request, 100 No results found, 140 Syntax error, 150 Semantic error etc. These would make it easier to google for help and find Eurostat website. Also, when querying for a dataset that does not exist / is not otherwise available maybe it would be helpful to print the old note stored in msg object:
Especially if in some special cases when content(resp)$error is empty / does not exist:
So there could be a check for that as well. These examples could also be added to eurostat package tests. |
Now updated with the recommended changes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reviewed your code with the line-specific comments that should be listed here.
Additionally, the empty status message problem still persists and there are no unit tests checking if things work.
> get_eurostat("", filter = list(fromTimePeriod = 2005, untilTimePeriod = 2007))
Error in get_eurostat_json(id, filters, type = type, stringsAsFactors = stringsAsFactors, :
Status : , error id : No results found , label :
The error message is now changed to
|
Alright, thank you for your work, I'll merge the PR |
Return informative get_eurostat_json error messages to the user #261