Skip to content
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

Custom class for gcs_get_object() 40x errors #153

Closed
wlandau opened this issue Dec 15, 2021 · 4 comments
Closed

Custom class for gcs_get_object() 40x errors #153

wlandau opened this issue Dec 15, 2021 · 4 comments

Comments

@wlandau
Copy link

wlandau commented Dec 15, 2021

When I run tryCatch(googleCloudStorageR::gcs_get_object(...), error = function(condition_object) browser()), on an object that does not exist, I find that condition_object has class c("simpleError", "error", "condition"). Would it be possible to throw a more specific error class for HTML error codes 400-404? For ropensci/targets#722, this would eliminate confusion with other kinds of errors in targets:::gcp_gcs_head().

@wlandau
Copy link
Author

wlandau commented Dec 15, 2021

rlang::abort(..., class = "http_400") is a convenient alternative to stop(...) for this.

@MarkEdmondson1234
Copy link
Collaborator

This looks like something that would be best done in googleAuthR or gargle, but will investigate.

@MarkEdmondson1234
Copy link
Collaborator

For now its implemented here via

# https://adv-r.hadley.nz/conditions.html
abort_http <- function(status_code, msg = NULL){
  rlang::abort(paste0("http_",status_code), 
        message = paste(status_code, "error when attempting HTTP -", msg)
  )
}

It would be better in googleAuthR though

@MarkEdmondson1234
Copy link
Collaborator

This was done in googleAuthR - thanks for idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants