Documentation
¶
Index ¶
- type Error
- func (z *Error) DecodeMsg(dc *msgp.Reader) (err error)
- func (z *Error) EncodeMsg(en *msgp.Writer) (err error)
- func (e *Error) Error() string
- func (z *Error) MarshalMsg(b []byte) (o []byte, err error)
- func (z *Error) Msgsize() (s int)
- func (z *Error) UnmarshalMsg(bts []byte) (o []byte, err error)
- func (e *Error) WithData(data []byte) *Error
- func (e *Error) WithTraceID(traceID string) *Error
- type T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Error ¶
type Error struct {
Code uint16 `msg:"c"` // 错误码 (用于程序逻辑判断,如 1001=UserNotFound)
Msg string `msg:"m"` // 错误信息 (用于日志和人类阅读)
Data []byte `msg:"d,allownil"` // (可选) 附加数据,例如具体的校验失败字段
TraceID string `msg:"t"` // (可选) 分布式追踪 ID
}
所有错误,由这个接口包装,以便以msgp序列化,然后传递
func (*Error) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
func (*Error) Msgsize ¶
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*Error) UnmarshalMsg ¶
UnmarshalMsg implements msgp.Unmarshaler
func (*Error) WithTraceID ¶
type T ¶
type T = uint16
const ( ClientInternal T = 400 //参数错误 ClientInvalidArgs T = 402 //参数错误 CodeClientForbidden T = 403 //禁止访问 ClientNotFound T = 404 //找不到 ClientMethodNotAllowed T = 405 //方法禁用 ClientCallError T = 406 //方法禁用 ClientReturnInvalid T = 407 //返回类型错误 ClientTooManyRequests T = 429 //请求过多 ClientSendChanExhaust T = 497 //请求队列已经耗尽 ClientCanceled T = 498 //请求取消 ClientStandardError T = 499 //客户端标准错误 )
client
const ( ServerInternal T = 500 //服务器内部错误 ServerDeadlineExceeded T = 504 //网关超时 ServerServiceNotFound T = 505 //服务未找到 ServerStandardError T = 599 //服务器标准错误 )
server
const ( RemoteInternal T = 600 //远程内部错误 RemoteTimeout T = 601 //远程超时错误 RemoteStandardError T = 699 //远程标准错误 )
remote
const None T = 0
是一个假错误,不是真的错误,既没有返回值,也没有错误,需要,就是作为特殊功能的返回.eg:重置客户端的EOS 如果表示为空的返回值,就需要一个接受的值,但是没有内定的接受。Error是固定的,所以用这个不是错误的错误表示没有返回值
Click to show internal directories.
Click to hide internal directories.