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

Improve error message for problems with URLs #811

Merged
merged 4 commits into from
Nov 20, 2023
Merged

Conversation

juliasilge
Copy link
Member

Closes #810

We now see a message like this when we end up in a bad URL situation, such as trying pin_read() on a full path or forgetting a trailing slash for a vanity URL:

library(pins)
board <- board_connect_url(c(
  numbers = "https://colorado.posit.co/rsc/some-nice-numbers"
))
board |> pin_read("numbers")
#> Error in `object_read()`:
#> ! Cannot automatically read pin:
#> • Is your pin specified as a full path? Retrieve it with `pin_download()`
#> • Is your pin specified via a URL that is not a full path, such as a Posit
#>   Connect vanity URL? Remember to include a trailing slash `/`
#> Backtrace:
#>     ▆
#>  1. └─pins::pin_read(board, "numbers")
#>  2.   └─pins:::object_read(meta)
#>  3.     └─cli::cli_abort(...)
#>  4.       └─rlang::abort(...)

Created on 2023-11-17 with reprex v2.0.2

@slodge do you have any feedback on this?

@juliasilge juliasilge marked this pull request as ready for review November 17, 2023 21:13
@slodge
Copy link

slodge commented Nov 20, 2023

Error message reads much better ... I can't promise I'll read it :)

... but I read the previous one - so there's hope!

I'd guess there was "guessing" the code could have done in the connect_url case - e.g. looking for a file extension, detecting the html response, etc... but I agree that'd be overkill for the case where the user (me!) had typed the url wrong 👍

Thanks!

@juliasilge
Copy link
Member Author

Most of the basic URL parsing tools out there (urltools::url_parse() and httr::parse_url()) don't really give us directly what we'd need to distinguish between use cases, so I do think it's better to improve the error message rather than try for more guessing.

I appreciate the report a lot -- thanks again! 🙌

@juliasilge juliasilge merged commit 45f2eee into main Nov 20, 2023
@juliasilge juliasilge deleted the improve-error-urls branch November 20, 2023 17:41
Copy link

github-actions bot commented Dec 5, 2023

This pull request has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improved error reporting for redirected mistyped pins in board_connect_url
2 participants