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
@@ -21,6 +21,7 @@ defmodule MusicLibraryWeb.CollectionLive.Show do
alias MusicLibrary.{Records, RecordSets, ScrobbleActivity}
alias MusicLibrary.Records.Similarity
alias MusicLibraryWeb.ErrorMessages
alias Phoenix.LiveView.JS
@impl true
@@ -370,7 +371,8 @@ defmodule MusicLibraryWeb.CollectionLive.Show do
socket
|> put_toast(
:error,
gettext("Error refreshing MusicBrainz data") <> "," <> inspect(reason)
gettext("Error refreshing MusicBrainz data") <>
": " <> ErrorMessages.friendly_message(reason)
)}
end
end
@@ -389,7 +391,7 @@ defmodule MusicLibraryWeb.CollectionLive.Show do
socket
|> put_toast(
:error,
gettext("Error") <> "," <> inspect(reason)
gettext("Error") <> ": " <> ErrorMessages.friendly_message(reason)
)}
end
end
@@ -409,7 +411,7 @@ defmodule MusicLibraryWeb.CollectionLive.Show do
socket
|> put_toast(
:error,
gettext("Error refreshing cover") <> "," <> inspect(reason)
gettext("Error refreshing cover") <> ": " <> ErrorMessages.friendly_message(reason)
)}
end
end
@@ -429,7 +431,7 @@ defmodule MusicLibraryWeb.CollectionLive.Show do
socket
|> put_toast(
:error,
gettext("Error extracting colors") <> ": " <> inspect(reason)
gettext("Error extracting colors") <> ": " <> ErrorMessages.friendly_message(reason)
)}
end
end
@@ -448,7 +450,7 @@ defmodule MusicLibraryWeb.CollectionLive.Show do
socket
|> put_toast(
:error,
gettext("Error") <> "," <> inspect(reason)
gettext("Error") <> ": " <> ErrorMessages.friendly_message(reason)
)}
end
end