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

Better error message when path argument does not start with a forward slash #26

Open
CameronBieganek opened this issue Apr 21, 2020 · 0 comments

Comments

@CameronBieganek
Copy link

Example:

julia> HTTP.URI(; scheme="https", host="julialang.org", path="foo/bar")
ERROR: ArgumentError: merge(::HTTP.URIs.URI; scheme::String, userinfo::SubString{String}, host::String, port::SubString{String}, path::String, query::SubString{String}, fragment::SubString{String}) requires !(scheme in ["http", "https"]) || (isempty(path) || path[1] == '/')
Stacktrace:
 [1] macro expansion at /Users/bieganek/.julia/packages/HTTP/GkPBm/src/debug.jl:52 [inlined]
 [2] merge(::HTTP.URIs.URI; scheme::String, userinfo::SubString{String}, host::String, port::SubString{String}, path::String, query::SubString{String}, fragment::SubString{String}) at /Users/bieganek/.julia/packages/HTTP/GkPBm/src/URIs.jl:81
 [3] #URI#3 at /Users/bieganek/.julia/packages/HTTP/GkPBm/src/URIs.jl:66 [inlined]
 [4] top-level scope at REPL[31]:1

That's not a terribly helpful error message. If you look really closely you can see the (isempty(path) || path[1] == '/') part at the end, but it's easy to miss.

In addition to a better error message, it would be a good idea to explicitly mention in the docstring that path must start with a forward slash.

@CameronBieganek CameronBieganek changed the title Better error message when path argument does not start with a forward slash` Better error message when path argument does not start with a forward slash Apr 21, 2020
@fredrikekre fredrikekre transferred this issue from JuliaWeb/HTTP.jl Apr 28, 2021
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

1 participant