errcode

package
v1.3.77 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

	InvalidErrorCode = &ErrorCode{httpx.JsonResponse{
		Status: 0,
		Errno:  constInvalidErrorBaseIndex,
		Code:   "FatalErrorInvalidErrorCode",
	}}
)
View Source
var (
	ErrSuccess             = New(http.StatusOK)
	ErrInsufficientStorage = New(http.StatusInsufficientStorage)
	ErrInternalServerError = New(http.StatusInternalServerError)
	ErrTimeout             = New(http.StatusGatewayTimeout)
	ErrForbidden           = New(http.StatusForbidden)
	ErrNotFound            = New(http.StatusNotFound)
	ErrConflict            = New(http.StatusConflict)
	ErrUnauthorized        = New(http.StatusUnauthorized)
	ErrPreconditionFailed  = New(http.StatusPreconditionFailed)
	ErrTooManyRequests     = New(http.StatusTooManyRequests)
	ErrNotImplemented      = New(http.StatusNotImplemented)
	ErrBadRequest          = New(http.StatusBadRequest)

	ErrLengthRequired               = New(http.StatusLengthRequired)
	ErrRequestURITooLong            = New(http.StatusRequestURITooLong)
	ErrUnsupportedMediaType         = New(http.StatusUnsupportedMediaType)
	ErrRequestedRangeNotSatisfiable = New(http.StatusRequestedRangeNotSatisfiable)
	ErrExpectationFailed            = New(http.StatusExpectationFailed)
	ErrTeapot                       = New(http.StatusTeapot)
	ErrMisdirectedRequest           = New(http.StatusMisdirectedRequest)
	ErrUnprocessableEntity          = New(http.StatusUnprocessableEntity)
	ErrLocked                       = New(http.StatusLocked)
	ErrFailedDependency             = New(http.StatusFailedDependency)
	ErrUpgradeRequired              = New(http.StatusUpgradeRequired)
	ErrPreconditionRequired         = New(http.StatusPreconditionRequired)
	ErrRequestHeaderFieldsTooLarge  = New(http.StatusRequestHeaderFieldsTooLarge)
	ErrUnavailableForLegalReasons   = New(http.StatusUnavailableForLegalReasons)
	ErrMultiStatus                  = New(http.StatusMultiStatus)
	ErrAlreadyReported              = New(http.StatusAlreadyReported)
	ErrIMUsed                       = New(http.StatusIMUsed)

	ErrMultipleChoices   = New(http.StatusMultipleChoices)
	ErrMovedPermanently  = New(http.StatusMovedPermanently)
	ErrFound             = New(http.StatusFound)
	ErrSeeOther          = New(http.StatusSeeOther)
	ErrNotModified       = New(http.StatusNotModified)
	ErrUseProxy          = New(http.StatusUseProxy)
	ErrTemporaryRedirect = New(http.StatusTemporaryRedirect)
	ErrPermanentRedirect = New(http.StatusPermanentRedirect)

	ErrPaymentRequired       = New(http.StatusPaymentRequired)
	ErrMethodNotAllowed      = New(http.StatusMethodNotAllowed)
	ErrNotAcceptable         = New(http.StatusNotAcceptable)
	ErrProxyAuthRequired     = New(http.StatusProxyAuthRequired)
	ErrRequestTimeout        = New(http.StatusRequestTimeout)
	ErrGone                  = New(http.StatusGone)
	ErrRequestEntityTooLarge = New(http.StatusRequestEntityTooLarge)
	ErrTooEarly              = New(http.StatusTooEarly)

	ErrBadGateway                    = New(http.StatusBadGateway)
	ErrServiceUnavailable            = New(http.StatusServiceUnavailable)
	ErrGatewayTimeout                = New(http.StatusGatewayTimeout)
	ErrHTTPVersionNotSupported       = New(http.StatusHTTPVersionNotSupported)
	ErrVariantAlsoNegotiates         = New(http.StatusVariantAlsoNegotiates)
	ErrLoopDetected                  = New(http.StatusLoopDetected)
	ErrNotExtended                   = New(http.StatusNotExtended)
	ErrNetworkAuthenticationRequired = New(http.StatusNetworkAuthenticationRequired)
)
View Source
var (
	ErrWrongSign       = New(http.StatusBadRequest, "WrongSign")
	ErrExpiredRequest  = New(http.StatusBadRequest, "ExpiredRequest")
	ErrObjectExist     = New(http.StatusBadRequest, "ObjectExist")
	ErrObjectNotExist  = New(http.StatusBadRequest, "ObjectNotExist")
	ErrUserExist       = New(http.StatusBadRequest, "UserExist")
	ErrUserNotExist    = New(http.StatusBadRequest, "UserNotExist")
	ErrSessionNotExist = New(http.StatusBadRequest, "SessionNotExist")
	ErrSessionExist    = New(http.StatusBadRequest, "SessionExist")

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

	ErrNotReady        = New(http.StatusInternalServerError, "NotReady")
	ErrInvalidDataType = New(http.StatusInternalServerError, "InvalidDataType")
)

Functions

func DumpErrorCodes added in v1.3.75

func DumpErrorCodes() string

func ErrStrResp added in v1.3.75

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

func IsNotFound added in v1.3.75

func IsNotFound(err error) bool

func Len added in v1.3.75

func Len() int

func New added in v1.3.75

func New(errno int, opts ...string) func(errs ...error) *ErrorCode

Types

type ErrorCode added in v1.3.75

type ErrorCode struct {
	httpx.JsonResponse
}

func ErrHttpStatus added in v1.3.75

func ErrHttpStatus(status int) *ErrorCode

func (*ErrorCode) GetBadRequest added in v1.3.75

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

func (*ErrorCode) GetCode added in v1.3.75

func (ec *ErrorCode) GetCode() string

func (*ErrorCode) GetErrno added in v1.3.75

func (ec *ErrorCode) GetErrno() int

func (*ErrorCode) GetHttpStatus added in v1.3.75

func (ec *ErrorCode) GetHttpStatus() int

func (*ErrorCode) GetInternalError added in v1.3.75

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

func (*ErrorCode) GetSuccess added in v1.3.75

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

func (*ErrorCode) HttpCode added in v1.3.75

func (ec *ErrorCode) HttpCode() int

HttpCode required by interface httpx.JsonResponseError

func (*ErrorCode) NewRequestId added in v1.3.75

func (ec *ErrorCode) NewRequestId() string

func (*ErrorCode) ToCode added in v1.3.75

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

func (*ErrorCode) ToHttpStatus added in v1.3.75

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

func (*ErrorCode) ToHttpXJsonResponse added in v1.3.75

func (ec *ErrorCode) ToHttpXJsonResponse() *httpx.JsonResponse

ConvertJsonResponse implement HttpxJsonResponseWrapper

Jump to

Keyboard shortcuts

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