defmodule AprsmeWeb.Components.ErrorBoundary do @moduledoc """ Error boundary component for gracefully handling errors in LiveView. This component wraps other components and catches errors, displaying a user-friendly error message instead of crashing the entire view. """ use Phoenix.Component import AprsmeWeb.CoreComponents alias Phoenix.LiveView.Socket @doc """ Wraps content in an error boundary that catches and displays errors gracefully. ## Examples <.error_boundary id="map-error-boundary"> <%= live_render(@socket, AprsmeWeb.MapLive.Index) %> """ attr :id, :string, required: true attr :class, :string, default: nil slot :inner_block, required: true slot :fallback do attr :error, :string end def error_boundary(assigns) do ~H"""
We're sorry, but something unexpected happened. The error has been logged and we'll look into it. Please try refreshing the page.