Documentation
¶
Overview ¶
Package awserr provides shared sentinel errors for AWS service stubs. Service packages wrap these sentinels so callers can use errors.Is to match any service error against a shared sentinel.
Index ¶
Constants ¶
const ErrAlreadyExists sentinelError = "resource already exists"
ErrAlreadyExists is a sentinel indicating a resource already exists.
const ErrConflict sentinelError = "conflict"
ErrConflict is a sentinel indicating a conflicting state or concurrent operation.
const ErrInvalidParameter sentinelError = "invalid parameter"
ErrInvalidParameter is a sentinel indicating an invalid or missing parameter.
const ErrNotFound sentinelError = "resource not found"
ErrNotFound is a sentinel indicating a requested resource does not exist.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New creates an error with the given message that wraps the given sentinel. This preserves the service-specific error message while enabling errors.Is to match the shared sentinel.
Types ¶
type APIError ¶
type APIError struct {
// Code is the AWS error code (e.g. "ResourceNotFoundException"). For the
// JSON protocols it may include the Coral namespace prefix
// (e.g. "com.amazonaws.dynamodb.v20120810#ResourceNotFoundException").
Code string
// Message is the human-readable error message.
Message string
// HTTPStatus is the HTTP status code to return (e.g. 400, 404, 409).
HTTPStatus int
}
APIError is a protocol-agnostic description of an AWS API error. Services declare a table mapping their wrapped sentinel errors (see New) to an APIError, then call Write to serialise it for the wire.
func Classify ¶
Classify maps err to an APIError using table. Each table key is a sentinel (or wrapped sentinel) and is matched against err with errors.Is, so callers can wrap sentinels with New/Newf and still classify them here. The first matching entry wins; if nothing matches, fallback is returned (typically a 500 InternalFailure). The matched entry's Message is overridden with err's message when err carries a more specific one via New/Newf.
type Protocol ¶
type Protocol int
Protocol identifies the AWS wire protocol used to encode an error envelope. Different AWS services speak different protocols, so the same logical error (an APIError) must be serialised differently depending on the service.
const ( // ProtocolJSON10 is the AWS JSON 1.0 protocol (e.g. DynamoDB). Errors are // encoded as {"__type":"<Code>","message":"<Message>"} with a CRC32 header. ProtocolJSON10 Protocol = iota // ProtocolJSON11 is the AWS JSON 1.1 protocol (e.g. Kinesis, many newer // services). Same envelope as JSON 1.0 with a different Content-Type. ProtocolJSON11 // ProtocolQueryXML is the AWS Query protocol (e.g. classic SQS/SNS/EC2). // Errors are wrapped in <ErrorResponse><Error>...</Error></ErrorResponse>. ProtocolQueryXML // ProtocolRestXML is the AWS REST-XML protocol (e.g. S3). Errors are // encoded as a bare <Error>...</Error> document. ProtocolRestXML )