diff --git a/lib/aprsme_web/live/map_live/index.ex b/lib/aprsme_web/live/map_live/index.ex index 8233f13..77dff31 100644 --- a/lib/aprsme_web/live/map_live/index.ex +++ b/lib/aprsme_web/live/map_live/index.ex @@ -180,7 +180,16 @@ defmodule AprsmeWeb.MapLive.Index do if tracked_callsign == "" do nil else - Packets.get_latest_packet_for_callsign(tracked_callsign) + try do + Packets.get_latest_packet_for_callsign(tracked_callsign) + rescue + # Handle database connection errors gracefully (especially in tests) + DBConnection.OwnershipError -> + nil + + _ -> + nil + end end # Start packet batcher for efficient updates diff --git a/lib/aprsme_web/live/map_live/navigation.ex b/lib/aprsme_web/live/map_live/navigation.ex index fea93e4..cebf99c 100644 --- a/lib/aprsme_web/live/map_live/navigation.ex +++ b/lib/aprsme_web/live/map_live/navigation.ex @@ -40,9 +40,18 @@ defmodule AprsmeWeb.MapLive.Navigation do @spec handle_callsign_tracking(binary(), map(), integer(), boolean()) :: {map(), integer()} def handle_callsign_tracking(tracked_callsign, map_center, map_zoom, has_explicit_url_params) do if tracked_callsign != "" and not has_explicit_url_params do - case Packets.get_latest_packet_for_callsign(tracked_callsign) do - %{lat: lat, lon: lon} when is_number(lat) and is_number(lon) -> - {%{lat: lat, lng: lon}, 12} + try do + case Packets.get_latest_packet_for_callsign(tracked_callsign) do + %{lat: lat, lon: lon} when is_number(lat) and is_number(lon) -> + {%{lat: lat, lng: lon}, 12} + + _ -> + {map_center, map_zoom} + end + rescue + # Handle database connection errors gracefully (especially in tests) + DBConnection.OwnershipError -> + {map_center, map_zoom} _ -> {map_center, map_zoom}