Skip to content

Commit

Permalink
Use inspect/1 instead of to_string/1 on errors
Browse files Browse the repository at this point in the history
It fixes #26
  • Loading branch information
edgurgel committed Oct 9, 2014
1 parent 0be49fc commit 6d8b6aa
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/httpoison/base.ex
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ defmodule HTTPoison.Base do
{:ok, id} ->
%HTTPoison.AsyncResponse { id: id }
{:error, reason} ->
raise HTTPoison.HTTPError, message: to_string(reason)
raise HTTPoison.HTTPError, message: inspect(reason)
end
end

Expand Down
11 changes: 11 additions & 0 deletions test/httpoison_base_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,15 @@ defmodule HTTPoisonBaseTest do

assert validate :hackney
end

test "request raises error tuple" do
expect(:hackney, :request, 5, {:error, {:closed, "Something happened"}})


assert_raise HTTPoison.HTTPError, "{:closed, \"Something happened\"}", fn ->
HTTPoison.get("http://localhost")
end

assert validate :hackney
end
end
2 changes: 1 addition & 1 deletion test/httpoison_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ defmodule HTTPoisonTest do
end

test "exception" do
assert_raise HTTPoison.HTTPError, "econnrefused", fn ->
assert_raise HTTPoison.HTTPError, ":econnrefused", fn ->
HTTPoison.get "localhost:1"
end
end
Expand Down

0 comments on commit 6d8b6aa

Please sign in to comment.