errors

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ERR_CONTEXT_LENGTH_EXCEEDED = NewApiError(400, "context_length_exceeded", "Please reduce the length of the messages.", "invalid_request_error", "messages")
	ERR_INVALID_API_KEY         = NewApiError(401, "invalid_api_key", "Incorrect API key provided or has been disabled.", "invalid_request_error", "")
	ERR_MODEL_NOT_FOUND         = NewApiError(404, "model_not_found", "The model does not exist or you do not have access to it.", "invalid_request_error", "")
	ERR_INSUFFICIENT_QUOTA      = NewApiError(429, "insufficient_quota", "You exceeded your current quota.", "insufficient_quota", "")
	ERR_RATE_LIMIT_EXCEEDED     = NewApiError(429, "rate_limit_exceeded", "Rate limit reached, Please try again later.", "requests", "")
)

Functions

func As

func As(err error, target any) bool

func Is

func Is(err, target error) bool

func New

func New(text string) error

func NewApiError

func NewApiError(httpStatusCode int, code any, message, typ string, param any) error

func NewRequestError

func NewRequestError(httpStatusCode int, err error) error

func Newf

func Newf(format string, args ...any) error

Types

type ApiError

type ApiError struct {
	HttpStatusCode int    `json:"-"`
	Code           any    `json:"code"`
	Message        string `json:"message"`
	Type           string `json:"type"`
	Param          any    `json:"param"`
}

func (*ApiError) Error

func (e *ApiError) Error() string

func (*ApiError) UnmarshalJSON

func (e *ApiError) UnmarshalJSON(data []byte) (err error)

type ErrorResponse

type ErrorResponse struct {
	Error *ApiError `json:"error,omitempty"`
}

type RequestError

type RequestError struct {
	HttpStatusCode int
	Err            error
}

func (*RequestError) Error

func (e *RequestError) Error() string

func (*RequestError) Unwrap

func (e *RequestError) Unwrap() error

Jump to

Keyboard shortcuts

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