errors

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ERR_NIL                          = NewError(500, -1, "", "fastapi_error")
	ERR_UNKNOWN                      = NewError(500, -1, "Unknown Error", "fastapi_error")
	ERR_INTERNAL_ERROR               = NewError(500, 500, "Internal Error", "fastapi_error")
	ERR_NO_AVAILABLE_KEY             = NewError(500, "fastapi_error", "No available key", "fastapi_error")
	ERR_NO_AVAILABLE_MODEL_AGENT     = NewError(500, "fastapi_error", "No available model agent", "fastapi_error")
	ERR_NO_AVAILABLE_MODEL_AGENT_KEY = NewError(500, "fastapi_error", "No available model agent key", "fastapi_error")
	ERR_NOT_AUTHORIZED               = NewError(403, "fastapi_error", "Not Authorized", "fastapi_error")
	ERR_NOT_FOUND                    = NewError(404, "unknown_url", "Unknown request URL", "invalid_request_error")
	ERR_NOT_API_KEY                  = NewError(401, "invalid_request_error", "You didn't provide an API key.", "invalid_request_error")
	ERR_INVALID_API_KEY              = NewError(401, "invalid_api_key", "Incorrect API key provided or has been disabled.", "fastapi_request_error")
	ERR_API_KEY_DISABLED             = NewError(401, "api_key_disabled", "Key has been disabled.", "fastapi_request_error")
	ERR_INVALID_USER                 = NewError(401, "invalid_user", "User does not exist or has been disabled.", "fastapi_request_error")
	ERR_USER_DISABLED                = NewError(401, "user_disabled", "User has been disabled.", "fastapi_request_error")
	ERR_INVALID_APP                  = NewError(401, "invalid_app", "App does not exist or has been disabled.", "fastapi_request_error")
	ERR_APP_DISABLED                 = NewError(401, "app_disabled", "App has been disabled.", "fastapi_error")
	ERR_MODEL_NOT_FOUND              = NewError(404, "model_not_found", "The model does not exist or you do not have access to it.", "fastapi_request_error")
	ERR_MODEL_DISABLED               = NewError(401, "model_disabled", "Model has been disabled.", "fastapi_request_error")
	ERR_INSUFFICIENT_QUOTA           = NewError(429, "insufficient_quota", "You exceeded your current quota.", "insufficient_quota")
)

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 NewError

func NewError(status int, code any, message, typ string) error

func Newf

func Newf(format string, args ...interface{}) error

Types

type FastAPIError

type FastAPIError struct {
	Err *openai.APIError `json:"error,omitempty"`
}

func (*FastAPIError) ErrCode

func (e *FastAPIError) ErrCode() any

func (*FastAPIError) ErrMessage

func (e *FastAPIError) ErrMessage() string

func (*FastAPIError) ErrType

func (e *FastAPIError) ErrType() string

func (*FastAPIError) Error

func (e *FastAPIError) Error() string

func (*FastAPIError) Status

func (e *FastAPIError) Status() int

func (*FastAPIError) Unwrap

func (e *FastAPIError) Unwrap() error

type IFastAPIError

type IFastAPIError interface {
	Unwrap() error
	Status() int
	ErrCode() any
	ErrMessage() string
	ErrType() string
}

func Error

func Error(err error) IFastAPIError

Jump to

Keyboard shortcuts

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