errors

package
v1.4.5 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CodeSystemError                   = "E0000"
	CodeInvalidCredentials            = "E0001"
	CodeUserDisable                   = "E0002"
	CodeUserStatusUnknown             = "E0003"
	CodeUserNeedResetPassword         = "E0004"
	CodeUserInactive                  = "E0005"
	CodeTooManyLoginFailures          = "E0006"
	CodePasswordBaseGeneralTooSimple  = "E0010"
	CodePasswordBaseSafeTooSimple     = "E0011"
	CodePasswordBaseVerySafeTooSimple = "E0012"
	CodePasswordCannotContainUsername = "E0013"
	CodePasswordTooShort              = "E0014"
	CodePasswordRepetition            = "E0015"
	CodePasswordTooSimple             = "E0016"
	CodeRequestTooFrequently          = "E0429"
	CodeAppMemberCannotBeEmpty        = "E1101"
	CodeAppCannotBeDelete             = "E1102"
)

Variables

View Source
var (
	InternalServerError = func() error { return NewServerError(http.StatusInternalServerError, "Internal server error") }

	NotLoginError     = func() error { return NewServerError(http.StatusInternalServerError, "Not logged in") }
	BadRequestError   = func() error { return NewServerError(http.StatusBadRequest, "Invalid Request") }
	ParameterError    = func(msg string) error { return NewServerError(http.StatusBadRequest, "Parameter Error: "+msg) }
	UnauthorizedError = func() error { return NewServerError(http.StatusUnauthorized, "Invalid identity information") }
	StatusNotFound    = func(name string) errors.Error { return NewServerError(http.StatusNotFound, name+" Not Found") }
	StatusForbidden   = func(name string) errors.Error { return NewServerError(http.StatusForbidden, name+" StatusForbidden") }
	NotFoundError     = func() error { return NewServerError(http.StatusNotFound, "record not found") }
)

Functions

func Is

func Is(err, target error) bool

func IsNotFount

func IsNotFount(err error) bool

func LackParameterError

func LackParameterError(name string) error

func New

func New(text string) error

func NewMultipleServerError

func NewMultipleServerError(status int, prefix string, code ...string) *errors.Errors

func NewServerError

func NewServerError(status int, msg string, code ...string) errors.Error

func WithMessage

func WithMessage(err error, msg string) error

func WithServerError

func WithServerError(status int, err error, msg string, code ...string) errors.Error

Types

type ServerError

type ServerError interface {
	Code() string
	StatusCode() int
	json.Marshaler
	fmt.Stringer
	error
}

Jump to

Keyboard shortcuts

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