Normalized Dropbox API error.
Every Magpie function returns {:error, %Magpie.Error{}} when Dropbox
answers with a non-success status:
status— the HTTP status code (e.g.409)summary— Dropbox'serror_summarystring when present (e.g."path/not_found/.."),nilotherwisebody— the full decoded error payload
It is also an exception, so it can be raised — Magpie.Pager streams do
exactly that, since a Stream cannot return an error tuple
mid-enumeration:
case Magpie.Files.create_folder(client, "/Existing") do
{:ok, %{"metadata" => metadata}} -> metadata
{:error, %Magpie.Error{status: 409, summary: "path/conflict" <> _}} -> :already_exists
{:error, error} -> raise error
end
Summary
Functions
Builds a Magpie.Error from an HTTP status and a decoded response body,
extracting Dropbox's error_summary when present.
Types
@type t() :: %Magpie.Error{ __exception__: term(), body: term(), status: pos_integer(), summary: String.t() | nil }
Functions
Builds a Magpie.Error from an HTTP status and a decoded response body,
extracting Dropbox's error_summary when present.