Skip to content

Commit

Permalink
Merge pull request #553 from xypron/http_error
Browse files Browse the repository at this point in the history
lorawan_connector_http: handling http errors
  • Loading branch information
gotthardp committed Dec 8, 2018
2 parents c7d52fb + b26d613 commit eb0f24d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/lorawan_connector_http.erl
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,14 @@ handle_info({gun_response, C, StreamRef, Fin, 401, Headers},
end,
{noreply, fin_stream(StreamRef, Fin, State3)};
handle_info({gun_response, C, StreamRef, Fin, Status, _Headers},
State=#state{pid=C, streams=Streams}) ->
State=#state{pid = C, streams = Streams, conn = #connector{uri = Uri}}) ->
if
Status < 300 ->
ok;
Status >= 300 ->
{_, URI, _, _} = maps:get(StreamRef, Streams),
lager:debug("HTTP request to ~p failed: ~B", [URI, Status]),
{Path, _, _, _} = maps:get(StreamRef, Streams),
lager:debug("HTTP request failed: ~p, ~p", [Status, {Uri, Path}]),
lorawan_utils:throw_warning(connector_http, {http_error, {Status, Uri, Path}}),
ok
end,
{noreply, fin_stream(StreamRef, Fin, State)};
Expand Down

0 comments on commit eb0f24d

Please sign in to comment.