Skip to content

Commit 24a3908

Browse files
Paul Wilsonedgurgel
Paul Wilson
authored andcommitted
Keep location in HTTPoison.Base.__using__/1
1 parent 5920e19 commit 24a3908

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

lib/httpoison/base.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ defmodule HTTPoison.Base do
219219
@type params :: Request.params()
220220

221221
defmacro __using__(_) do
222-
quote do
222+
quote location: :keep do
223223
@behaviour HTTPoison.Base
224224

225225
@type request :: HTTPoison.Base.request()

test/httpoison_base_test.exs

+13-3
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,16 @@ defmodule HTTPoisonBaseTest do
142142
assert HTTPoison.get("http://localhost") == {:error, %HTTPoison.Error{reason: reason}}
143143
end
144144

145+
test "stack trace preserved on error" do
146+
expect(:hackney, :request, fn _, _, _, _, _ -> {:error, {:error, "whatevs"}} end)
147+
148+
HTTPoison.get!("http://localhost")
149+
rescue
150+
_e ->
151+
[{HTTPoison, :request!, 5, file_line} | _] = __STACKTRACE__
152+
assert {:ok, ~c"lib/httpoison/base.ex"} = Keyword.fetch(file_line, :file)
153+
end
154+
145155
test "passing connect_timeout option" do
146156
expect(:hackney, :request, fn
147157
:post, "http://localhost", [], "body", [connect_timeout: 12345] ->
@@ -221,7 +231,7 @@ defmodule HTTPoisonBaseTest do
221231
[
222232
socks5_pass: "secret",
223233
socks5_user: "user",
224-
proxy: {:socks5, 'localhost', 1080}
234+
proxy: {:socks5, ~c"localhost", 1080}
225235
] ->
226236
{:ok, 200, "headers", :client}
227237
end)
@@ -232,7 +242,7 @@ defmodule HTTPoisonBaseTest do
232242
"localhost",
233243
"body",
234244
[],
235-
proxy: {:socks5, 'localhost', 1080},
245+
proxy: {:socks5, ~c"localhost", 1080},
236246
socks5_user: "user",
237247
socks5_pass: "secret"
238248
) ==
@@ -246,7 +256,7 @@ defmodule HTTPoisonBaseTest do
246256
headers: [],
247257
method: :post,
248258
options: [
249-
proxy: {:socks5, 'localhost', 1080},
259+
proxy: {:socks5, ~c"localhost", 1080},
250260
socks5_user: "user",
251261
socks5_pass: "secret"
252262
],

0 commit comments

Comments
 (0)