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

Catch Hackney errors using '{:error, reason}' tuple format #141

Merged
merged 1 commit into from
May 27, 2016

Conversation

luizvarela
Copy link
Contributor

This will fix #117

This PR tries to fix the errors raised by Hackney, when we try to send a get request to an empty URL an exception is raised:

iex(1)> HTTPoison.get(" ")
** (exit) :badarg
       (kernel) gen_tcp.erl:148: :gen_tcp.connect/4
      (hackney) src/hackney_connect.erl:245: :hackney_connect.do_connect/5
      (hackney) src/hackney_connect.erl:36: :hackney_connect.connect/5
      (hackney) src/hackney.erl:328: :hackney.request/5
    (httpoison) lib/httpoison/base.ex:396: HTTPoison.Base.request/9

So, would be nice to return {:error, reason} for all these errors.
For example:

iex(1)> HTTPoison.get(" ")

{:error, %HTTPoison.Error{id: nil, reason: :badarg}}

@edgurgel
Copy link
Owner

Thanks for the PR! I don't "love" catching all the errors but it will be consistent with our API.

@edgurgel edgurgel merged commit fbdd1e6 into edgurgel:master May 27, 2016
@edgurgel
Copy link
Owner

🎉 <3

@luizvarela luizvarela deleted the catch-hackney-errors branch May 30, 2016 03:54
@luizvarela
Copy link
Contributor Author

Thanks @edgurgel 👍

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

Successfully merging this pull request may close these issues.

Unable to catch hackney errors
2 participants