errors

package
v0.0.79 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 29, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

http_error_handling.go This package provides utility functions and structures for handling and categorizing HTTP error responses.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNonRetryableStatusCode added in v0.0.58

func IsNonRetryableStatusCode(resp *http.Response) bool

IsNonRetryableStatusCode checks if the provided response indicates a non-retryable error.

func IsRateLimitError

func IsRateLimitError(resp *http.Response) bool

IsRateLimitError checks if the provided response indicates a rate limit error.

func IsRetryableStatusCode added in v0.0.52

func IsRetryableStatusCode(statusCode int) bool

IsRetryableStatusCode checks if the provided HTTP status code is considered retryable.

func IsTransientError

func IsTransientError(resp *http.Response) bool

IsTransientError checks if an error or HTTP response indicates a transient error.

func TranslateStatusCode

func TranslateStatusCode(resp *http.Response) string

TranslateStatusCode provides a human-readable message for HTTP status codes.

Types

type APIError

type APIError struct {
	StatusCode int    // HTTP status code
	Type       string // A brief identifier for the type of error (e.g., "RateLimit", "BadRequest", etc.)
	Message    string // Human-readable message
}

APIError represents a structured API error response.

func HandleAPIError

func HandleAPIError(resp *http.Response, log logger.Logger) *APIError

HandleAPIError handles error responses from the API, converting them into a structured error if possible.

func (*APIError) Error

func (e *APIError) Error() string

Error returns a string representation of the APIError.

type StructuredError

type StructuredError struct {
	Error struct {
		Code    string `json:"code"`
		Message string `json:"message"`
	} `json:"error"`
}

StructuredError represents a structured error response from the API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL