What do you think is the best way to handle errors on actions (not forms), like the delete Button. I see two ways:
- Use Changeset and show the errors on the flash message (when using fullstack)
- Returning an error on the corresponding method and showing it in the flash message
def delete(model) do
if .... do
...
:ok
else
{:error, :whatever}
end
end
case delete(model) do
ok ->
...
{:error, :whatever} ->
put_flash(socket, :error, "Whatever")
error ->
raise "Case not handled"
end
Thanks