elixir-tesla / tesla

The flexible HTTP client library for Elixir, with support for middleware and multiple adapters.
MIT License
2.01k stars 348 forks source link

Be more explict on `:no_scheme` error reason #657

Closed LauraBeatris closed 7 months ago

LauraBeatris commented 9 months ago

Potential improvement, not an actual bug:

Nowadays, if an invalid URL is provided to plug Tesla.Middleware.BaseUrl, then the following error is returned: :no_scheme

If the URL gets incorrectly formatted by mistake, it's not explicit that's the actual reason for the error. IMO the DX would be better here if the error was more specific, such as :invalid_url or missing_url_protocol.

yordis commented 9 months ago

Hey @LauraBeatris, as far as I can tell, https://github.com/elixir-tesla/tesla/blob/master/lib/tesla/middleware/base_url.ex doesn't do anything special other than adding the base URL.

I will assume that :no_scheme comes from the underlying HTTP client that you are using.

It would be helpful to confirm this.

So, I am not sure if Tesla should do much in that regard.