errors

package
v0.0.35 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 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 HandleAPIError

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

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

func IsNonRetryableError

func IsNonRetryableError(resp *http.Response) bool

IsNonRetryableError 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 IsTransientError

func IsTransientError(resp *http.Response) bool

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

func TranslateStatusCode

func TranslateStatusCode(statusCode int) 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 (*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