europepmc icon indicating copy to clipboard operation
europepmc copied to clipboard

Error if no results in epmc_search?

Open cstubben opened this issue 7 years ago • 3 comments

I sometimes run epmc_search in a loop, and if no results are found, it exits with an error. Right now I'm checking error messages, but it might be better if "No results found" returns a message and empty table instead?

if (hits == 0){
  message("There are no results matching your query") 
  md <- tibble()
}else{
  ...
}
attr(md, "hit_count") <- hits
return(md)

cstubben avatar Apr 26 '17 18:04 cstubben

Agreed, it is more sensible to return NULL and a message when no results are found. Will implement it.

njahn82 avatar Apr 26 '17 19:04 njahn82

Great, thanks. At least with an empty table you can still add the hit_count attribute, but NULL works too.

cstubben avatar Apr 26 '17 20:04 cstubben

@cstubben is now on master branch, hope, it works for you!

njahn82 avatar May 18 '17 16:05 njahn82