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:
Moritz 2026-01-13 14:05:46 +01:00
parent 77ae5c4888
commit a22081f288
Signed by: moritz
GPG key ID: 1020A035E5DD0824
5 changed files with 130 additions and 23 deletions

View file

@ -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)