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 payloadrequest_id— Dropbox's request identifier, useful when contacting support
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, %Magpie.FolderMetadata{} = folder} -> folder
{:error, %Magpie.Error{status: 409, summary: "path/conflict" <> _}} -> :already_exists
{:error, error} -> raise error
end
Summary
Functions
Returns whether an error represents failed authentication or authorization.
Returns whether Dropbox reported a path, file, or folder conflict.
Returns whether an error represents a content integrity mismatch.
Builds a Magpie.Error from an HTTP status and a decoded response body,
extracting Dropbox's error_summary when present.
Returns whether Dropbox reported that the requested resource was not found.
Returns whether Dropbox rate-limited the request.
Returns whether retrying the operation may succeed without changing it.
Types
@type t() :: %Magpie.Error{ __exception__: term(), body: term(), request_id: String.t() | nil, status: pos_integer(), summary: String.t() | nil }
Functions
Returns whether an error represents failed authentication or authorization.
Returns whether Dropbox reported a path, file, or folder conflict.
Returns whether an error represents a content integrity mismatch.
Builds a Magpie.Error from an HTTP status and a decoded response body,
extracting Dropbox's error_summary when present.
OAuth 2 errors (Magpie.Auth) have no error_summary — their error
field is a plain string such as "invalid_grant", which is used as the
summary instead.
iex> Magpie.Error.new(409, %{"error_summary" => "path/conflict/folder/.."}).summary
"path/conflict/folder/.."
iex> Magpie.Error.new(400, %{"error" => "invalid_grant"}).summary
"invalid_grant"
Returns whether Dropbox reported that the requested resource was not found.
Returns whether Dropbox rate-limited the request.
Returns whether retrying the operation may succeed without changing it.