appcues / mojito

An easy-to-use Elixir HTTP client, built on the low-level Mint library.
https://hexdocs.pm/mojito/Mojito.html
MIT License
349 stars 34 forks source link

Passing in a nil URL returns a hard-to-debug error #11

Closed intentionally-left-nil closed 5 years ago

intentionally-left-nil commented 5 years ago

Calling `Mojito.request(:get, nil) will return the following error:

{:error,
 %Mojito.Error{
   message: nil,
   reason: %FunctionClauseError{
     args: nil,
     arity: 2,
     clauses: nil,
     function: :from_string,
     kind: nil,
     module: Fuzzyurl
   }
 }}

I somewhat expected Dialyzer to pick this up, but it didn't at least for my project. It would be better in my opinion to add a guard clause preventing this somewhat common user behavior. Doing so would generate an easy to understand error message. I will open a PR to consider for this issue

gamache commented 5 years ago

0.1.1 fixes this. Thanks again!