PubsubGrpc.Error (PubsubGrpc v0.4.2)
View SourceStructured error type for PubsubGrpc operations.
All errors returned by the library are wrapped in this struct, providing consistent error handling across authentication, validation, connection, and gRPC API errors.
Fields
code- An atom categorizing the error (e.g.,:not_found,:validation_error)message- A human-readable error descriptiondetails- The original error term (e.g.,%GRPC.RPCError{}, exception struct)grpc_status- The integer gRPC status code when applicable,nilotherwise
Examples
case PubsubGrpc.create_topic("my-project", "my-topic") do
{:ok, topic} -> topic
{:error, %PubsubGrpc.Error{code: :already_exists}} -> "Topic already exists"
{:error, %PubsubGrpc.Error{code: :unauthenticated}} -> "Auth failed"
{:error, %PubsubGrpc.Error{} = err} -> "Error: #{err}"
end
Summary
Functions
Creates a new error from a gRPC error.
Creates a new error with the given code and message.
Types
@type t() :: %PubsubGrpc.Error{ code: atom(), details: term(), grpc_status: non_neg_integer() | nil, message: String.t() }
Functions
@spec from_grpc_error(GRPC.RPCError.t()) :: t()
Creates a new error from a gRPC error.
Maps the gRPC status code to a descriptive atom code and preserves
the original error in details.
Creates a new error with the given code and message.