Skip to content

Commit

Permalink
handle otp client error
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonyshull committed Dec 12, 2024
1 parent 1ece540 commit 604e274
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/dotcom_web/live/trip_planner.ex
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,20 @@ defmodule DotcomWeb.Live.TripPlanner do
{:noreply, new_socket}
end

@impl true
def handle_async("get_itinerary_groups", {:ok, {:error, errors}}, socket) do
error =
errors
|> Enum.map(errors, &Map.get(&1, :description))
|> Enum.join(", ")

new_socket =
socket
|> assign(:results, Map.put(@state.results, :error, error))

{:noreply, new_socket}
end

@impl true
def handle_async("get_itinerary_groups", {:ok, result}, socket) when is_binary(result) do
new_socket =
Expand All @@ -90,6 +104,7 @@ defmodule DotcomWeb.Live.TripPlanner do
{:noreply, new_socket}
end

@impl true
def handle_async("get_itinerary_groups", {:exit, reason}, socket) do
new_socket =
socket
Expand Down

0 comments on commit 604e274

Please sign in to comment.