Documentation
¶
Index ¶
Constants ¶
const ( ExitOK = 0 ExitError = 1 ExitAuth = 2 ExitNotFound = 3 ExitValidation = 4 ExitRateLimit = 5 ExitConflict = 6 ExitServer = 7 )
Exit code constants for structured error handling.
Variables ¶
This section is empty.
Functions ¶
func ErrorTypeFromStatus ¶
ErrorTypeFromStatus maps an HTTP status code to a string error type.
func ExitCodeFromStatus ¶
ExitCodeFromStatus maps an HTTP status code to a structured exit code.
func HintFromStatus ¶
HintFromStatus returns a helpful hint string for well-known error statuses. Returns an empty string for statuses that do not have a standard hint.
Types ¶
type APIError ¶
type APIError struct {
ErrorType string `json:"error_type"`
Status int `json:"status"`
Message string `json:"message"`
Hint string `json:"hint,omitempty"`
Request *RequestInfo `json:"request,omitempty"`
RetryAfter *int `json:"retry_after,omitempty"`
}
APIError is a structured error with an HTTP status, typed error category, human-readable message, optional hint, and optional request context.
func NewFromHTTP ¶
NewFromHTTP constructs an APIError from an HTTP response status, body text, and the originating request method and path.
func (*APIError) WriteStderr ¶
func (e *APIError) WriteStderr()
WriteStderr writes the JSON-encoded error to os.Stderr.
type RequestInfo ¶
RequestInfo holds metadata about the HTTP request that triggered the error.