ecode

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package ecode is the package that unifies the definition of http error codes or grpc error codes here.

Index

Constants

This section is empty.

Variables

View Source
var (
	Success = errcode.Success

	InvalidParams       = errcode.InvalidParams
	Unauthorized        = errcode.Unauthorized
	InternalServerError = errcode.InternalServerError
	NotFound            = errcode.NotFound
	Timeout             = errcode.Timeout
	TooManyRequests     = errcode.TooManyRequests
	Forbidden           = errcode.Forbidden
	LimitExceed         = errcode.LimitExceed
	Conflict            = errcode.Conflict
	TooEarly            = errcode.TooEarly

	DeadlineExceeded   = errcode.DeadlineExceeded
	AccessDenied       = errcode.AccessDenied
	MethodNotAllowed   = errcode.MethodNotAllowed
	ServiceUnavailable = errcode.ServiceUnavailable

	Canceled           = errcode.Canceled
	Unknown            = errcode.Unknown
	PermissionDenied   = errcode.PermissionDenied
	ResourceExhausted  = errcode.ResourceExhausted
	FailedPrecondition = errcode.FailedPrecondition
	Aborted            = errcode.Aborted
	OutOfRange         = errcode.OutOfRange
	Unimplemented      = errcode.Unimplemented
	DataLoss           = errcode.DataLoss
)

http system level error code, error code range 10000~20000

View Source
var (
	StatusSuccess = errcode.StatusSuccess

	StatusCanceled            = errcode.StatusCanceled
	StatusUnknown             = errcode.StatusUnknown
	StatusInvalidParams       = errcode.StatusInvalidParams
	StatusDeadlineExceeded    = errcode.StatusDeadlineExceeded
	StatusNotFound            = errcode.StatusNotFound
	StatusAlreadyExists       = errcode.StatusAlreadyExists
	StatusPermissionDenied    = errcode.StatusPermissionDenied
	StatusResourceExhausted   = errcode.StatusResourceExhausted
	StatusFailedPrecondition  = errcode.StatusFailedPrecondition
	StatusAborted             = errcode.StatusAborted
	StatusOutOfRange          = errcode.StatusOutOfRange
	StatusUnimplemented       = errcode.StatusUnimplemented
	StatusInternalServerError = errcode.StatusInternalServerError
	StatusServiceUnavailable  = errcode.StatusServiceUnavailable
	StatusDataLoss            = errcode.StatusDataLoss
	StatusUnauthorized        = errcode.StatusUnauthorized

	StatusTimeout          = errcode.StatusTimeout
	StatusTooManyRequests  = errcode.StatusTooManyRequests
	StatusForbidden        = errcode.StatusForbidden
	StatusLimitExceed      = errcode.StatusLimitExceed
	StatusMethodNotAllowed = errcode.StatusMethodNotAllowed
	StatusAccessDenied     = errcode.StatusAccessDenied
	StatusConflict         = errcode.StatusConflict
)

rpc system level error code, with status prefix, error code range 30000~40000

View Source
var (
	ErrCreateUserExample     = errcode.NewError(userExampleBaseCode+1, "failed to create "+userExampleName)
	ErrDeleteByIDUserExample = errcode.NewError(userExampleBaseCode+2, "failed to delete "+userExampleName)
	ErrUpdateByIDUserExample = errcode.NewError(userExampleBaseCode+3, "failed to update "+userExampleName)
	ErrGetByIDUserExample    = errcode.NewError(userExampleBaseCode+4, "failed to get "+userExampleName+" details")
	ErrListUserExample       = errcode.NewError(userExampleBaseCode+5, "failed to list of "+userExampleName)
)

userExample business-level http error codes. the userExampleNO value range is 1~100, if the same error code is used, it will cause panic.

View Source
var (
	StatusCreateUserExample     = errcode.NewRPCStatus(_userExampleBaseCode+1, "failed to create "+_userExampleName)
	StatusDeleteByIDUserExample = errcode.NewRPCStatus(_userExampleBaseCode+2, "failed to delete "+_userExampleName)
	StatusUpdateByIDUserExample = errcode.NewRPCStatus(_userExampleBaseCode+3, "failed to update "+_userExampleName)
	StatusGetByIDUserExample    = errcode.NewRPCStatus(_userExampleBaseCode+4, "failed to get "+_userExampleName+" details")
	StatusListUserExample       = errcode.NewRPCStatus(_userExampleBaseCode+5, "failed to list of "+_userExampleName)
)

userExample business-level rpc error codes. the _userExampleNO value range is 1~100, if the same error code is used, it will cause panic.

View Source
var GetErrorCode = errcode.GetErrorCode

GetErrorCode get error code from error

View Source
var GetStatusCode = errcode.GetStatusCode

GetStatusCode get status code from error returned by RPC invoke

View Source
var SkipResponse = errcode.SkipResponse
View Source
var StatusSkipResponse = errcode.SkipResponse

StatusSkipResponse is only use for grpc-gateway

Functions

func Any

func Any(key string, val interface{}) errcode.Detail

Any kev-value

Types

This section is empty.

Jump to

Keyboard shortcuts

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