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
|
|
@ -118,7 +118,7 @@ defmodule MvWeb.RoleLive.Index do
|
|||
|
||||
@spec load_roles(map() | nil) :: [Mv.Authorization.Role.t()]
|
||||
defp load_roles(actor) do
|
||||
opts = if actor, do: [actor: actor], else: []
|
||||
opts = MvWeb.LiveHelpers.ash_actor_opts(actor)
|
||||
|
||||
case Authorization.list_roles(opts) do
|
||||
{:ok, roles} -> Enum.sort_by(roles, & &1.name)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue