errors

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: Apache-2.0 Imports: 9 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) ServerError { return NewServerError(http.StatusNotFound, name+" Not Found") }
	StatusForbidden   = func(name string) ServerError { 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 WithMessage

func WithMessage(err error, msg string) error

Types

type MultipleServerError

type MultipleServerError struct {
	// contains filtered or unexported fields
}

func NewMultipleServerError

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

func (*MultipleServerError) Append

func (m *MultipleServerError) Append(err error)

func (MultipleServerError) Code

func (m MultipleServerError) Code() string

func (MultipleServerError) Error

func (m MultipleServerError) Error() string

func (MultipleServerError) HasError

func (m MultipleServerError) HasError() bool

func (MultipleServerError) MarshalJSON

func (m MultipleServerError) MarshalJSON() ([]byte, error)

func (MultipleServerError) StatusCode

func (m MultipleServerError) StatusCode() int

func (MultipleServerError) String

func (m MultipleServerError) String() string

type ServerError

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

func NewServerError

func NewServerError(status int, msg string, code ...string) ServerError

func WithServerError

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

Jump to

Keyboard shortcuts

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