Replace inspect(reason) with friendly error messages

Closes #81
This commit is contained in:
Claudio Ortolina
2026-03-05 20:25:13 +00:00
parent e8f393c5a0
commit 08f7565d44
18 changed files with 542 additions and 64 deletions
@@ -9,6 +9,7 @@ defmodule MusicLibraryWeb.CollectionLive.Index do
alias MusicLibrary.Collection
alias MusicLibrary.Records
alias MusicLibraryWeb.CollectionLive.Show
alias MusicLibraryWeb.ErrorMessages
@default_records_list_params %{
query: "",
@@ -272,20 +273,14 @@ defmodule MusicLibraryWeb.CollectionLive.Index do
|> put_toast(:info, gettext("Record imported successfully"))
|> push_navigate(to: ~p"/collection/#{record.id}")}
{:error, %Ecto.Changeset{} = changeset} ->
{:error, reason} ->
{:noreply,
socket
|> put_toast(
:error,
gettext("Error importing record") <> "," <> inspect(changeset.errors)
gettext("Error importing record") <> ": " <> ErrorMessages.friendly_message(reason)
)
|> push_patch(to: ~p"/collection")}
{:error, reason} ->
{:noreply,
socket
|> put_toast(:error, gettext("Error importing record") <> "," <> inspect(reason))
|> push_patch(to: ~p"/collection")}
end
end