Documentation ¶
Index ¶
- Constants
- Variables
- func Cause(err error) error
- func CreateBaseErrCode()
- func Fatal(err error, msg ...string)
- func FromGRPCCode(code codes.Code) int
- func Stack(err error) string
- func ToGRPCCode(code int) codes.Code
- func Wrap(err error, format string, a ...interface{}) error
- func WrapErr(err error, code ErrCode) error
- type BatchError
- type Converter
- type ErrCode
- type Error
- type ErrorInter
- type ErrorModels
- type Status
- func (*Status) Descriptor() ([]byte, []int)deprecated
- func (x *Status) GetCode() uint64
- func (x *Status) GetMessage() string
- func (x *Status) GetMetadata() map[string]string
- func (x *Status) GetReason() string
- func (*Status) ProtoMessage()
- func (x *Status) ProtoReflect() protoreflect.Message
- func (x *Status) Reset()
- func (x *Status) String() string
- func (s *Status) StringTo16() string
- type StatusFunc
Constants ¶
View Source
const ( // ClientClosed is non-standard http status code, // which defined by nginx. // https://httpstatus.in/499/ ClientClosed = 499 )
Variables ¶
View Source
var File_pkg_errorx_errorx_proto protoreflect.FileDescriptor
Functions ¶
func CreateBaseErrCode ¶
func CreateBaseErrCode()
func FromGRPCCode ¶
FromGRPCCode converts a gRPC error code into the corresponding HTTP response status.
func ToGRPCCode ¶
ToGRPCCode converts an HTTP error code into the corresponding gRPC response status.
Types ¶
type BatchError ¶
type BatchError struct {
// contains filtered or unexported fields
}
A BatchError is an error that can hold multiple errors.
func (*BatchError) Add ¶
func (be *BatchError) Add(errs ...error)
Add adds errs to be, nil errors are ignored.
func (*BatchError) Err ¶
func (be *BatchError) Err() error
Err returns an error that represents all errors.
type Converter ¶
type Converter interface { // ToGRPCCode converts an HTTP error code into the corresponding gRPC response status. ToGRPCCode(code int) codes.Code // FromGRPCCode converts a gRPC error code into the corresponding HTTP response status. FromGRPCCode(code codes.Code) int }
Converter is a status converter.
var DefaultConverter Converter = statusConverter{}
type ErrCode ¶
type ErrCode uint64
const ( ErrCodeOK ErrCode = errCodeBase + iota ErrCodeStandard //默认缺少指定error-code类型 ErrCodeJsonErr ErrCodeNotAuthorized ErrCodeBusy ErrCodeTimeOut ErrCodeParamsErr ErrCodeNotFound ErrCodeNetWorkErr ErrCodeUnknown ErrCodeLogPathNotSet ErrCodeLogFileClosed ErrCodeWatcherFileStop ErrCodeAssertionValue ErrCodeGetPathValue ErrCodeMsgTypeMismatch ErrCodeBaseMax = errCodeBase | errMask )
const ( ErrRpcCodeParentGroupNotExist ErrCode = errCodeRpcServer + iota ErrRpcServerNotFound ErrRpcCodeGroupNotEmpty ErrRpcCodeConfIsBusy2 ErrRpcCodeMobileRepeat ErrRpcCodeGroupIndepFailed ErrRpcCodeGroupLevelTooBig ErrRpcCodeCapacityTooBig ErrRpcCodeEmailRepeat ErrRpcCodeDelTopGroup ErrRpcCodeAgentMax = errCodeRpcServer | errMask )
const ( ErrApiCodeParentGroupNotExist ErrCode = errCodeApiServer + iota ErrApiCodeShouldBindJSON ErrApiCodeGroupNotEmpty ErrApiCodeConfIsBusy2 ErrApiCodeMobileRepeat ErrApiCodeGroupIndepFailed ErrApiCodeGroupLevelTooBig ErrApiCodeCapacityTooBig ErrApiCodeEmailRepeat ErrApiCodeDelTopGroup ErrApiCodeAgentMax = errCodeApiServer | errMask )
type Error ¶
type Error struct { *Status `json:"status,omitempty"` Cause error `json:"cause,omitempty"` Stack string `json:"-"` }
func New ¶
func New(err error, opts ...StatusFunc) *Error
func Unauthorized ¶
Unauthorized new 未授权错误 error that is mapped to a 401 response.
func (*Error) GRPCStatus ¶
GRPCStatus returns the Status represented by se.
type ErrorInter ¶
type ErrorModels ¶
type ErrorModels []*Status
type Status ¶
type Status struct { Code uint64 `protobuf:"varint,1,opt,name=Code,proto3" json:"Code,omitempty"` Reason string `protobuf:"bytes,2,opt,name=reason,proto3" json:"reason,omitempty"` Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"` Metadata map[string]string `` /* 157-byte string literal not displayed */ // contains filtered or unexported fields }
func (*Status) Descriptor
deprecated
func (*Status) GetMessage ¶
func (*Status) GetMetadata ¶
func (*Status) ProtoMessage ¶
func (*Status) ProtoMessage()
func (*Status) ProtoReflect ¶
func (x *Status) ProtoReflect() protoreflect.Message
func (*Status) StringTo16 ¶
type StatusFunc ¶
type StatusFunc func(status *Status)
func WithField ¶ added in v1.0.3
func WithField(key, value string) StatusFunc
func WithReason ¶
func WithReason(reason string) StatusFunc
Click to show internal directories.
Click to hide internal directories.