response

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: MIT Imports: 6 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

This section is empty.

Types

type APIError

type APIError struct {
	StatusCode int                    // HTTP status code
	Type       string                 // A brief identifier for the type of error
	Message    string                 // Human-readable message
	Detail     string                 // Detailed error message
	Errors     map[string]interface{} // A map to hold various error fields
	Raw        string                 // Raw response body for unstructured errors
}

APIError represents a more flexible structure for API error responses.

func HandleAPIErrorResponse

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

HandleAPIErrorResponse attempts to parse the error response from the API and logs using the zap logger.

func (*APIError) Error

func (e *APIError) Error() string

Error returns a JSON 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