Documentation
¶
Overview ¶
Package errors defines typed application errors used for consistent API responses.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AppError ¶
type AppError struct {
// Code is stable machine-readable identifier.
Code Code
// Message is client-facing summary.
Message string
// StatusCode is HTTP status to write for this error.
StatusCode int
// Details is optional structured payload.
Details any
// Cause stores underlying internal error.
Cause error
}
AppError is the typed error model used across handlers and policies.
func AsAppError ¶
AsAppError extracts AppError from wrapped error chain.
func WithDetails ¶
WithDetails attaches structured details payload to AppError.
type Code ¶
type Code string
Code is a stable machine-readable API error identifier.
const ( // CodeInternal represents unexpected internal failures. CodeInternal Code = "internal_error" // CodeBadRequest represents invalid client input. CodeBadRequest Code = "bad_request" // CodeUnsupportedMedia represents unsupported request content type. CodeUnsupportedMedia Code = "unsupported_media_type" // CodeNotFound represents missing resources. CodeNotFound Code = "not_found" // CodeMethodNotAllowed represents unsupported HTTP method. CodeMethodNotAllowed Code = "method_not_allowed" CodeUnauthorized Code = "unauthorized" // CodeForbidden represents authorization failures. CodeForbidden Code = "forbidden" // CodeTooManyRequests represents rate limit exhaustion. CodeTooManyRequests Code = "too_many_requests" // CodeConflict represents state conflicts. CodeConflict Code = "conflict" // CodeTimeout represents request timeout failures. CodeTimeout Code = "timeout" // CodeDependencyFailure represents unavailable dependency failures. CodeDependencyFailure Code = "dependency_unavailable" )
Click to show internal directories.
Click to hide internal directories.