-
Notifications
You must be signed in to change notification settings - Fork 24
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
More verbose httr error message for get_file() #31
Comments
I like this feature very much. (See below for a reprex). Your current IPA example fails to give the intended error (i.e. it actually passes without any error messages). It's not clear if it should fail: your example trys to download a Word Doc and indeed That was a stopgap and should be revisited... in the meantime, are there any examples of # Get `ReadMe with Codebook.docx` (https://doi.org/10.7910/DVN/JGLOZF/GYZ7OQ, id = 2972336)
# master branch
library(dataverse)
get_file(2972336, server = "demo.dataverse.org") # wrong server
#> Error in get_file(2972336, server = "demo.dataverse.org"): Not Found (HTTP 404). # EdJeeOnGitHub fork branch
library(dataverse)
get_file(2972336, server = "demo.dataverse.org") # wrong server
#> Error in get_file(2972336, server = "demo.dataverse.org"): Not Found (HTTP 404). Failed to API endpoint does not exist on this server. Please check your code for typos, or consult our API guide at http://guides.dataverse.org.. Created on 2020-12-28 by the reprex package (v0.3.0) |
Thanks! Back in Nov 2019 it was definitely throwing errors but things seem to have changed quite a bit since then - I think the pull request was meant to be incorporated some time ago but seems to have fallen through the cracks. I haven't touched any dataverse data in a while now so don't have any handy candidates for test cases I'm afraid. |
I often find
get_file()
errors since the API can't return a certain file format. Since the dataverse API returns informative messages when a request fails it makes sense to pass this along in R instead of just the default fromhttr::stop_for_status()
.For instance:
after the PR will return:
instead of:
The text was updated successfully, but these errors were encountered: