Structured error type for GcpGcs operations.
Every error returned by the library is wrapped in this struct, giving consistent handling across authentication, validation, transport, and Google Cloud Storage API errors.
Fields
code— an atom categorizing the error (e.g.:not_found,:validation_error)message— a human-readable descriptiondetails— the original error term (decoded JSON body, exception, etc.)status— the integer HTTP status code when applicable,nilotherwise
Examples
case GcpGcs.get_object("my-bucket", "missing.txt") do
{:ok, object} -> object
{:error, %GcpGcs.Error{code: :not_found}} -> "no such object"
{:error, %GcpGcs.Error{code: :unauthenticated}} -> "auth failed"
{:error, %GcpGcs.Error{} = err} -> "Error: #{err}"
end
Summary
Functions
Builds an error from an HTTP response.
Maps a transport-level reason (Finch/Mint error) to an error struct.
Creates a new error with the given code and message.
Types
@type t() :: %GcpGcs.Error{ code: atom(), details: term(), message: String.t(), status: non_neg_integer() | nil }
Functions
@spec from_response(non_neg_integer(), term()) :: t()
Builds an error from an HTTP response.
Maps the status code to a descriptive atom and extracts the message from a
decoded GCS JSON error body (%{"error" => %{"message" => ...}}) when present.
Maps a transport-level reason (Finch/Mint error) to an error struct.
Creates a new error with the given code and message.