fix(import): return readable string for unreadable upload errors
File.read/1 only yields posix atoms, so the File.Error and bare-reason branches were unreachable, and :file.format_error/1 returns a charlist rather than a String. Normalize the error to a binary so it interpolates correctly in flash messages.
This commit is contained in:
parent
05f66ccf74
commit
c41d24113f
2 changed files with 34 additions and 7 deletions
|
|
@ -26,14 +26,8 @@ defmodule Mv.Membership.Import.ImportRunner do
|
|||
{:ok, content} ->
|
||||
{:ok, content}
|
||||
|
||||
{:error, reason} when is_atom(reason) ->
|
||||
{:error, :file.format_error(reason)}
|
||||
|
||||
{:error, %File.Error{reason: reason}} ->
|
||||
{:error, :file.format_error(reason)}
|
||||
|
||||
{:error, reason} ->
|
||||
{:error, Exception.message(reason)}
|
||||
{:error, to_string(:file.format_error(reason))}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue