code

package
v0.0.0-...-c820190 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ErrSuccess - 200: OK.
	ErrSuccess = iota + 100001

	// ErrUnknown - 500: Internal server error.
	ErrUnknown

	// ErrBind - 400: Error occurred while binding the request body to the struct.
	ErrBind

	// ErrValidation - 400: Validation failed.
	ErrValidation

	// ErrTokenInvalid - 401: Token invalid.
	ErrTokenInvalid

	// ErrPageNotFound - 404: Page not found.
	ErrPageNotFound
)

Common: basic errors. Code must start with 1xxxxx.

View Source
const (
	// ErrEncrypt - 401: Error occurred while encrypting the user password.
	ErrEncrypt int = iota + 100201

	// ErrSignatureInvalid - 401: Signature is invalid.
	ErrSignatureInvalid

	// ErrExpired - 401: Token expired.
	ErrExpired

	// ErrInvalidAuthHeader - 401: Invalid authorization header.
	ErrInvalidAuthHeader

	// ErrMissingHeader - 401: The `Authorization` header was empty.
	ErrMissingHeader

	// ErrPasswordIncorrect - 401: Password was incorrect.
	ErrPasswordIncorrect

	// PermissionDenied - 403: Permission denied.
	ErrPermissionDenied
)

common: authorization and authentication errors.

View Source
const (
	// ErrEncodingFailed - 500: Encoding failed due to an error with the data.
	ErrEncodingFailed int = iota + 100301

	// ErrDecodingFailed - 500: Decoding failed due to an error with the data.
	ErrDecodingFailed

	// ErrInvalidJSON - 500: Data is not valid JSON.
	ErrInvalidJSON

	// ErrEncodingJSON - 500: JSON data could not be encoded.
	ErrEncodingJSON

	// ErrDecodingJSON - 500: JSON data could not be decoded.
	ErrDecodingJSON

	// ErrInvalidYaml - 500: Data is not valid Yaml.
	ErrInvalidYaml

	// ErrEncodingYaml - 500: Yaml data could not be encoded.
	ErrEncodingYaml

	// ErrDecodingYaml - 500: Yaml data could not be decoded.
	ErrDecodingYaml
)

common: encode/decode errors.

View Source
const (
	// ErrDatabase - 500: Database error.
	ErrDatabase int = iota + 100101
	// ErrConnectDB - 500: Init db error.
	ErrConnectDB

	// ErrConnectGRPC - 500: Connect to grpc error.
	ErrConnectGRPC
)
View Source
const (
	// ErrGoodsNotFound - 404: Goods not found.
	ErrGoodsNotFound int = iota + 100501

	// ErrCategoryNotFound - 404: Category not found.
	ErrCategoryNotFound

	// ErrBrandNotFound - 500: Es unmarshal error.
	ErrEsUnmarshal
)
View Source
const (
	// ErrInventoryNotFound - 404: Inventory not found.
	ErrInventoryNotFound int = iota + 100601

	// ErrInvSellDetailNotFound - 400: Inventory sell detail not found.
	ErrInvSellDetailNotFound

	// ErrInvNotEnough - 400: Inventory not enough.
	ErrInvNotEnough
)
View Source
const (
	// ErrShopCartItemNotFound - 404: ShopCart item not found.
	ErrShopCartItemNotFound int = iota + 100701

	// ErrSubmitOrder - 400: Submit order error.
	ErrSubmitOrder

	// ErrOrderNotFound - 404: No Goods selected.
	ErrNoGoodsSelect
)
View Source
const (
	// ErrUserNotFound - 404: User not found.
	ErrUserNotFound int = iota + 100401

	// ErrUserAlreadyExists - 400: User already exists.
	ErrUserAlreadyExists

	// ErrUserPasswordIncorrect - 400: User password incorrect.
	ErrUserPasswordIncorrect

	// ErrSmsSend - 400: Send sms error.
	ErrSmsSend

	// ErrCodeNotExist - 400: Sms code incorrect or expired.
	ErrCodeNotExist

	// ErrCodeInCorrect - 400: Sms code incorrect.
	ErrCodeInCorrect

	// ErrCodeInvalidParam - 400: Invalid param.
	ErrCodeInvalidParam

	// ErrInit - 500: Init Discovery failed.
	ErrInit

	// ErrSmsIncorrect - 400: Sms code incorrect.
	ErrSmsIncorrect
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrCode

type ErrCode struct {
	//错误码
	C int

	//http的状态码
	HTTP int

	//扩展字段
	Ext string

	//引用文档
	Ref string
}

func (ErrCode) Code

func (e ErrCode) Code() int

func (ErrCode) HTTPStatus

func (e ErrCode) HTTPStatus() int

func (ErrCode) Reference

func (e ErrCode) Reference() string

func (ErrCode) String

func (e ErrCode) String() string

Jump to

Keyboard shortcuts

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