3
有沒有什麼辦法可以模式匹配httpoison
的錯誤響應?我這樣做模式匹配HTTpoison響應Elixir
case HTTPoison.get!(url, [], []) do
%HTTPoison.Error{reason: reason} ->
IO.inspect "Media: #{reason}!"
:timer.sleep(:timer.seconds(3))
do_loop(starting, ending, interval, camera_exid)
response ->
upload(response.status_code, response.body, starting, camera_exid)
do_loop(starting + interval, ending, interval, camera_exid)
end
但它並沒有趕上timeout
,給了我誤差
** (HTTPoison.Error) :timeout
(httpoison) lib/httpoison.ex:66: HTTPoison.request!/5
(extractor) lib/snapshot/snap_extractor.ex:67: Extractor.SnapExtractor.do_loop/4
(elixir) lib/enum.ex:651: Enum."-each/2-lists^foreach/1-0-"/2
(elixir) lib/enum.ex:651: Enum.each/2
我覺得我在錯誤的方式做吧..有什麼建議?
我剛剛使用了第二部分..謝謝:) – ijunaidfarooq