response

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

response/error.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 ParseContentTypeHeader added in v0.1.7

func ParseContentTypeHeader(header string) (string, map[string]string)

ParseContentTypeHeader parses the Content-Type header and extracts the MIME type and parameters.

Types

type APIError

type APIError struct {
	StatusCode int                    `json:"status_code" xml:"StatusCode"`            // HTTP status code
	Type       string                 `json:"type" xml:"Type"`                         // Type of error
	Message    string                 `json:"message" xml:"Message"`                   // Human-readable message
	Detail     string                 `json:"detail,omitempty" xml:"Detail,omitempty"` // Detailed error message
	Errors     map[string]interface{} `json:"errors,omitempty" xml:"Errors,omitempty"` // Additional error details
	Raw        string                 `json:"raw" xml:"Raw"`                           // Raw response body for debugging
}

APIError represents an api error response.

func HandleAPIErrorResponse

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

HandleAPIErrorResponse handles the HTTP error response from an API and logs the error.

func (*APIError) Error

func (e *APIError) Error() string

Error returns a string representation of the APIError, making it compatible with the error interface.

Jump to

Keyboard shortcuts

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