apiErrors

package
v0.5.13 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAPIError

func NewAPIError(status int, message string) error

func NewAPIErrorF

func NewAPIErrorF(status int, format string, a ...interface{}) error

func NewAPIErrorWithCause

func NewAPIErrorWithCause(message string, cause error) error

func NewBadRequestErrorF

func NewBadRequestErrorF(format string, a ...interface{}) error

func NewNotFoundErrorF

func NewNotFoundErrorF(format string, a ...interface{}) error

func NewUnauthorizedErrorF

func NewUnauthorizedErrorF(format string, a ...interface{}) error

Types

type APIError

type APIError struct {
	Status        int    `json:"code"`                // HTTP status code
	Message       string `json:"message"`             // human-readable message
	RequestID     string `json:"requestID,omitempty"` // ID to identify the request that caused this error
	OriginalError error  `json:"-"`
}

func AsAPIError added in v0.5.2

func AsAPIError(err error) (*APIError, bool)

func NewInternalServerError

func NewInternalServerError(originalError error) *APIError

func UnwrapAPIError

func UnwrapAPIError(err error) *APIError

UnwrapAPIError returns an API Error if one exists in the given error's chain or nil if no API Error exists in the chain.

func (*APIError) Error

func (a *APIError) Error() string

Jump to

Keyboard shortcuts

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