geemus/excon — pull request #292 by maxlinc (2013-10-14 00:02:59+00:00)
Title: excon should have clearer messages for unusable URIs

URI.parse is very lenient. It will parse even parse a string with no URI scheme. If you give a URI like this to Excon, you get a pretty cryptic error message, like:

```
can't convert nil into String (TypeError)
/Users/Thoughtworker/repos/rackspace/excon/lib/excon/connection.rb:93:in `initialize'
/Users/Thoughtworker/repos/rackspace/excon/lib/excon.rb:143:in `new'
/Users/Thoughtworker/repos/rackspace/excon/lib/excon.rb:143:in `new'
/Users/Thoughtworker/repos/rackspace/excon/tests/errors_tests.rb:5:in `block (2 levels) in '
```

It's hard to tell what tripped up Excon. I don't think Excon supports a default URI scheme, so I added the bare minimum assertion - making sure the URI has a scheme.

Note: I thought about putting the check in Excon::Connection, but then I'd need to manually reconstruct the URI if I want to include it in the error message.