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.
Example:
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
pathmust start with a forward slash.