Skip to content

Commit

Permalink
Gère erreur HTTP dans Transport.GTFSRT (#3683)
Browse files Browse the repository at this point in the history
* Fix exception

* Use inspect on error reason elsewhere
  • Loading branch information
AntoineAugusti authored Dec 28, 2023
1 parent 9b6534e commit 5e5b00a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion apps/transport/lib/jobs/resource_history_job.ex
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ defmodule Transport.Jobs.ResourceHistoryJob do
{:error, "Got a non 200 status: #{status}"}

{:error, %HTTPoison.Error{reason: reason}} ->
{:error, "Got an error: #{reason}"}
{:error, "Got an error: #{inspect(reason)}"}
end
end

Expand Down
2 changes: 1 addition & 1 deletion apps/transport/lib/transport/gtfs_rt.ex
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ defmodule Transport.GTFSRT do
{:error, "Got a non 200 HTTP status code: #{status_code}"}

{:error, %HTTPoison.Error{reason: reason}} ->
{:error, "Got an HTTP error: #{reason}"}
{:error, "Got an HTTP error: #{inspect(reason)}"}
end
end

Expand Down
2 changes: 1 addition & 1 deletion apps/transport/lib/transport_web/live/siri_querier_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ defmodule TransportWeb.Live.SIRIQuerierLive do
})

{:error, %HTTPoison.Error{reason: reason}} ->
socket |> assign(siri_response_error: reason, siri_response_status_code: nil)
socket |> assign(siri_response_error: inspect(reason), siri_response_status_code: nil)
end

{:noreply, socket}
Expand Down
10 changes: 8 additions & 2 deletions apps/transport/test/transport/gtfs_rt_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,15 @@ defmodule Transport.GTFSRTTest do
end

test "HTTPoison error" do
setup_http_response(@url, {:error, %HTTPoison.Error{reason: "SSL problemz"}})
reason =
{:tls_alert,
{:certificate_expired,
~c"TLS client: In state certify at ssl_handshake.erl:2065 generated CLIENT ALERT: Fatal - Certificate Expired\n"}}

assert {:error, "Got an HTTP error: SSL problemz"} == GTFSRT.decode_remote_feed(@url)
setup_http_response(@url, {:error, %HTTPoison.Error{reason: reason}})

{:error, reason} = GTFSRT.decode_remote_feed(@url)
assert reason =~ ~r"^Got an HTTP error:"
end
end

Expand Down

0 comments on commit 5e5b00a

Please sign in to comment.