DataONEorg / rdataone

R package for reading and writing data at DataONE data repositories
http://doi.org/10.5063/F1M61H5X
36 stars 19 forks source link

check packageId is a resource map before trying to `getDataPackage` #291

Open jeanetteclark opened 2 years ago

jeanetteclark commented 2 years ago

Recently I discovered that if getDataPackage is run on a pid with a formatId other than http://www.openarchives.org/ore/terms (in this case it was a resource map accidentally set with formatId text/csv, we get the exceedingly cryptic:

Trying urn:node:ARCTIC Error in if (!repeated && grepl("%[[:xdigit:]]{2}", URL, useBytes = TRUE)) return(URL) : missing value where TRUE/FALSE needed

I think it would be helpful if the function checked the sysmeta of that argument before proceeding, and gave an informative error message if it doesn't seem right.