Skip to content

Commit

Permalink
feat: log error with context on timeout (#2096)
Browse files Browse the repository at this point in the history
* feat: log error with context on timeout

* fix: raise on task exit

* chore: unnest anonymous fn
  • Loading branch information
sloanelybutsurely authored Jun 27, 2024
1 parent d6c7e4b commit 13b4be0
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions lib/screens/v2/candidate_generator/dup/departures.ex
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,21 @@ defmodule Screens.V2.CandidateGenerator.Dup.Departures do
create_station_with_routes_map_fn,
now,
ctx
)
),
on_timeout: :kill_task
)
|> Enum.map(fn {:ok, data} -> data end)
|> Enum.map(fn
{:ok, data} ->
data

{:exit, reason} ->
ctx =
Screens.Telemetry.context()
|> to_log()

Logger.error(["event=get_section_data.exit reason=#{reason} ", ctx])
raise "Failed to get section data"
end)
end
)
end
Expand Down Expand Up @@ -640,4 +652,8 @@ defmodule Screens.V2.CandidateGenerator.Dup.Departures do
|> Enum.flat_map(fn %{routes: routes} -> Enum.map(routes, &Route.icon/1) end)
|> Enum.uniq()
end

defp to_log(map) do
Enum.map_join(map, " ", fn {k, v} -> "#{k}=#{v}" end)
end
end

0 comments on commit 13b4be0

Please sign in to comment.