errcode

package
v0.0.0-...-1115455 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	OK = newErrCode(http.StatusOK)

	ErrInvalidErrorCode = &ErrorCode{httpx.JsonResponse{
		Status: 0,
		Errno:  constInvalidErrorBaseIndex,
		Code:   "FatalErrorInvalidErrorCode",
	}}

	// Code == http status
	ErrSuccess    = funcNewErrCode(http.StatusOK)
	ErrBatchError = funcNewErrCode(http.StatusOK, "InternalServerError")
	ErrPartlyOk   = funcNewErrCode(http.StatusOK, "PartlyOk")
	ErrErrorFound = funcNewErrCode(http.StatusOK, "ErrorFound")

	ErrInsufficientStorage = funcNewErrCode(http.StatusInsufficientStorage)
	ErrInternalServerError = funcNewErrCode(http.StatusInternalServerError)
	ErrTimeout             = funcNewErrCode(http.StatusGatewayTimeout)
	ErrForbidden           = funcNewErrCode(http.StatusForbidden)
	ErrNotFound            = funcNewErrCode(http.StatusNotFound)
	ErrConflict            = funcNewErrCode(http.StatusConflict)
	ErrUnauthorized        = funcNewErrCode(http.StatusUnauthorized)
	ErrPreconditionFailed  = funcNewErrCode(http.StatusPreconditionFailed)
	ErrTooManyRequests     = funcNewErrCode(http.StatusTooManyRequests)
	ErrNotImplemented      = funcNewErrCode(http.StatusNotImplemented)

	ErrFailedDependency    = funcNewErrCode(http.StatusFailedDependency, "No storage")
	ErrMaxBindingLimited   = funcNewErrCode(http.StatusBadRequest, "MaxBindingLimited")
	ErrBadRequest          = funcNewErrCode(http.StatusBadRequest)
	ErrUnsupportedDevice   = funcNewErrCode(http.StatusBadRequest, "UnsupportedDevice")
	ErrMissPublicParameter = funcNewErrCode(http.StatusBadRequest, "MissPublicParameter")
	ErrInvalidSumAlgo      = funcNewErrCode(http.StatusBadRequest, "InvalidSumAlgo")
	ErrIsDirectory         = funcNewErrCode(http.StatusBadRequest, "TargetIsDirectory")
	ErrSourceIsParent      = funcNewErrCode(http.StatusBadRequest, "SourceIsParent")
	ErrExpiredRequest      = funcNewErrCode(http.StatusBadRequest, "ExpiredRequest")
	ErrObjectExist         = funcNewErrCode(http.StatusBadRequest, "ObjectExist")
	ErrObjectNotExist      = funcNewErrCode(http.StatusBadRequest, "ObjectNotExist")
	ErrSessionNotExist     = funcNewErrCode(http.StatusBadRequest, "SessionNotExist")
	ErrNoNeedUpgrade       = funcNewErrCode(http.StatusBadRequest, "NoNeedUpgrade")
	ErrUserExist           = funcNewErrCode(http.StatusBadRequest, "UserExist")
	ErrWrongSign           = funcNewErrCode(http.StatusBadRequest, "WrongSign")
	ErrInvalidVrfCode      = funcNewErrCode(http.StatusBadRequest, "InvalidSmsCode")
	ErrExpiredVrfCode      = funcNewErrCode(http.StatusBadRequest, "ExpiredSmsCode")
	ErrInvalidDeviceId     = funcNewErrCode(http.StatusBadRequest, "InvalidDeviceId")
	ErrAlreadyFormated     = funcNewErrCode(http.StatusBadRequest, "AlreadyFormated")

	ErrDeviceAlreadyBound = funcNewErrCode(http.StatusBadRequest, "DeviceAlreadyBound")
	ErrDeviceOffline      = funcNewErrCode(http.StatusBadRequest, "DeviceOffline")

	ErrInvalidJwt      = funcNewErrCode(http.StatusUnauthorized, "InvalidJwt")
	ErrInvalidPassword = funcNewErrCode(http.StatusUnauthorized, "InvalidPassword")
	ErrInvalidNonce    = funcNewErrCode(http.StatusUnauthorized, "InvalidNonce")
	ErrExpiredNonce    = funcNewErrCode(http.StatusUnauthorized, "ExpiredNonce")
	ErrInvalidSign     = funcNewErrCode(http.StatusUnauthorized, "InvalidSign")
	ErrExpiredToken    = funcNewErrCode(http.StatusUnauthorized, "ExpiredToken")
	ErrInvalidToken    = funcNewErrCode(http.StatusUnauthorized, "InvalidToken")
	ErrInvalidIssuer   = funcNewErrCode(http.StatusUnauthorized, "InvalidIssuer")

	//4XXX 调用方错误
	//5XXX 服务器内部错误
	ErrConflictConnection = funcNewErrCode(http.StatusInternalServerError, "ConflictConnection")
	ErrInvalidDataType    = funcNewErrCode(http.StatusInternalServerError, "InvalidDataType")
	ErrEmptyKey           = funcNewErrCode(http.StatusInternalServerError, "EmptyKey")
	ErrEmptyPassword      = funcNewErrCode(http.StatusInternalServerError, "EmptyPassword")
	ErrRootUserDeletion   = funcNewErrCode(http.StatusInternalServerError, "RootUserDeletion")
)

Functions

func DumpErrorCodes

func DumpErrorCodes() string

func ErrStrResp

func ErrStrResp(status int, b any, format string, a ...any) error

func Len

func Len() int

Types

type ErrorCode

type ErrorCode struct {
	httpx.JsonResponse
}

func ErrHttpStatus

func ErrHttpStatus(status int) *ErrorCode

func (*ErrorCode) GetBadRequest

func (ec *ErrorCode) GetBadRequest() errcodex.ErrorCodeIf

func (*ErrorCode) GetCode

func (ec *ErrorCode) GetCode() string

func (*ErrorCode) GetErrno

func (ec *ErrorCode) GetErrno() int

func (*ErrorCode) GetHttpStatus

func (ec *ErrorCode) GetHttpStatus() int

func (*ErrorCode) GetInternalError

func (ec *ErrorCode) GetInternalError() errcodex.ErrorCodeIf

func (*ErrorCode) GetSuccess

func (ec *ErrorCode) GetSuccess() errcodex.ErrorCodeIf

func (*ErrorCode) HttpCode

func (ec *ErrorCode) HttpCode() int

HttpCode required by interface httpx.JsonResponseError

func (*ErrorCode) NewRequestId

func (ec *ErrorCode) NewRequestId() string

func (*ErrorCode) ToCode

func (ec *ErrorCode) ToCode(errno int) string

func (*ErrorCode) ToHttpStatus

func (ec *ErrorCode) ToHttpStatus(errno int) int

func (*ErrorCode) ToStringWithStack

func (ec *ErrorCode) ToStringWithStack()

Jump to

Keyboard shortcuts

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