From b26d6135d19781f84b2d201d524615fdc4d19b54 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Fri, 7 Dec 2018 21:42:28 +0000 Subject: [PATCH] lorawan_connector_http: handling http errors When the HTTP connector receives an HTTP error log the status and the path and not the password (closes #552) and create an event. Signed-off-by: Heinrich Schuchardt --- src/lorawan_connector_http.erl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lorawan_connector_http.erl b/src/lorawan_connector_http.erl index 0a79e6fd..9819fc28 100644 --- a/src/lorawan_connector_http.erl +++ b/src/lorawan_connector_http.erl @@ -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)};