sshkit.ex icon indicating copy to clipboard operation
sshkit.ex copied to clipboard

Return better error tuples (avoid string reason)

Open pmeinhardt opened this issue 8 years ago • 0 comments

In some cases, we're currently returning {:error, "binary with error message…"} tuples, which may complicate proper error handling because the binary message is harder to match against.

Instead, we should return structured error tuples, e.g.

{:error, {:interrupted, status}}

# …instead of
{:error, "SCP exited before completing the transfer (#{status})"}

lib/sshkit/scp/download.ex:170

See also http://michal.muskala.eu/2017/02/10/error-handling-in-elixir-libraries.html#okerror-tuples.

pmeinhardt avatar Jul 02 '17 06:07 pmeinhardt