Closed EdJeeOnGitHub closed 3 years ago
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
https://dataverse.harvard.edu/api/access/datafile/2972336?format=original
gives that error you posted but
https://dataverse.harvard.edu/api/access/datafile/2972336
but downloads the Word Doc fine. In #39 I changed so that querys/format args are only used when the target is an ingested file.
That was a stopgap and should be revisited... in the meantime, are there any examples of .tab
files for which we'd get an informative error message? We can put that in a testthat too.
# 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: