apierr

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UserFriendlyError

func UserFriendlyError(err *APIError) string

UserFriendlyError converts API errors to user-friendly messages

Types

type APIError

type APIError struct {
	StatusCode   int    `json:"-"`
	Code         string `json:"code,omitempty"`    // Backend error code (ACCESS_DENIED, NOT_FOUND, etc.)
	ErrorMessage string `json:"error,omitempty"`   // Legacy error field
	Message      string `json:"message,omitempty"` // Detailed error message
	Details      string `json:"details,omitempty"`
}

APIError represents an error response from the API

func ParseAPIError

func ParseAPIError(resp *http.Response) *APIError

ParseAPIError extracts error details from an HTTP response. NOTE: This function does NOT close resp.Body - caller is responsible for closing. This allows the caller to use defer resp.Body.Close() consistently.

func (*APIError) Error

func (e *APIError) Error() string

Jump to

Keyboard shortcuts

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