perrors

package
v0.1.17 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCodeInvalidRequest      ErrCode = ErrCode{"invalid_request", http.StatusBadRequest}
	ErrCodeInternalServer              = ErrCode{"internal_server_error", http.StatusInternalServerError}
	ErrCodeNotFound                    = ErrCode{"not_found", http.StatusNotFound}
	ErrCodeConflict                    = ErrCode{"conflict", http.StatusConflict}
	ErrCodeUnauthorized                = ErrCode{"unauthorized", http.StatusUnauthorized}
	ErrCodeForbidden                   = ErrCode{"forbidden", http.StatusForbidden}
	ErrCodeBadRequest                  = ErrCode{"bad_request", http.StatusBadRequest}
	ErrCodeMethodNotAllowed            = ErrCode{"method_not_allowed", http.StatusMethodNotAllowed}
	ErrCodeTooManyRequests             = ErrCode{"too_many_requests", http.StatusTooManyRequests}
	ErrCodeInternalServerError         = ErrCode{"internal_server_error", http.StatusInternalServerError}
	ErrCodeNotImplemented              = ErrCode{"not_implemented", http.StatusNotImplemented}
)

Functions

func New

func New(code ErrCode, msg string, err error, args ...map[string]interface{}) error

func NewErrInternalServerError

func NewErrInternalServerError(msg string, err error, args ...map[string]interface{}) error

func NewErrInvalidRequest

func NewErrInvalidRequest(msg string, err error, args ...map[string]interface{}) error

Types

type Err

type Err struct {
	Message    string                   `json:"-"`
	Err        string                   `json:"error"`
	Code       ErrCode                  `json:"-"`
	Stacktrace []string                 `json:"-"`
	Args       []map[string]interface{} `json:"args"`
}

func (Err) Error

func (e Err) Error() string

func (Err) HttpStatus

func (e Err) HttpStatus() int

func (Err) Print

func (e Err) Print(ctx context.Context)

type ErrCode

type ErrCode struct {
	Code   string `json:"code"`
	Status int    `json:"status"`
}

Jump to

Keyboard shortcuts

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