ropensci / openalexR

Getting bibliographic records from OpenAlex
https://docs.ropensci.org/openalexR/
Other
89 stars 19 forks source link

Handle large request errors #231

Closed yjunechoe closed 2 months ago

yjunechoe commented 2 months ago

Fixes #230

rkrug commented 2 months ago

Thanks - but I think this should be more than a message - it should raise an error. It would be difficult to find this error as nothing useful is returned (just an empty list), and when running scripts (in a quarto document) the messages are discarded.

yjunechoe commented 2 months ago

Yeah that's fair, though I think that involves a somewhat separate / larger issue of rethrowing errors. Currently, all HTTP request errors are handled with a message like this, so I've simply followed that format for 400. Perhaps others can comment on what they think about promoting these to errors.

yjunechoe commented 2 months ago

Actually sorry this is not true - HTTP errors are typically rethrown, and I think code 400 should fall under the typical case.

Should now error on large queries:

oa_request(query_url = q, count_only = TRUE)
#> Error in api_request(query_url, ua, query = query_ls, api_key = api_key): HTTP status 400 Request Line is too large