refactor: Replace bang calls with error handling in Index LiveViews
- Replace Ash.get!/Ash.destroy! with Ash.get/Ash.destroy - Add case statements for Forbidden, NotFound, and generic errors - Display user-friendly flash messages for all error cases - Use Enum.map_join/3 for efficient error formatting
This commit is contained in:
parent
77ae5c4888
commit
a22081f288
5 changed files with 130 additions and 23 deletions
|
|
@ -58,9 +58,8 @@ defmodule MvWeb.MemberLive.Index do
|
|||
@impl true
|
||||
def mount(_params, session, socket) do
|
||||
# Load custom fields that should be shown in overview (for display)
|
||||
# Note: Using Ash.read! (bang version) - errors will be handled by Phoenix LiveView
|
||||
# and result in a 500 error page. This is appropriate for LiveViews where errors
|
||||
# should be visible to the user rather than silently failing.
|
||||
# Errors in mount are handled by Phoenix LiveView and result in a 500 error page.
|
||||
# This is appropriate for initialization errors that should be visible to the user.
|
||||
actor = current_actor(socket)
|
||||
|
||||
custom_fields_visible =
|
||||
|
|
@ -727,8 +726,7 @@ defmodule MvWeb.MemberLive.Index do
|
|||
socket.assigns.custom_fields_visible
|
||||
)
|
||||
|
||||
# Note: Using Ash.read! - errors will be handled by Phoenix LiveView
|
||||
# This is appropriate for data loading in LiveViews
|
||||
# Errors in handle_params are handled by Phoenix LiveView
|
||||
actor = current_actor(socket)
|
||||
members = Ash.read!(query, actor: actor)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue