Documentation
¶
Index ¶
- Variables
- type ConnectRPCAdapter
- type Err
- func (e *Err) Clone() *Err
- func (e *Err) Error() string
- func (e *Err) GetCode() uint32
- func (e *Err) GetMsg() string
- func (e *Err) GetParams() map[string]any
- func (e *Err) GetUnderlyingError() error
- func (e *Err) Is(target error) bool
- func (e *Err) MarshalJSON() ([]byte, error)
- func (e *Err) SetErr(err error) *Err
- func (e *Err) SetMsg(format string, msg ...any) *Err
- func (e *Err) Unwrap() error
- func (e *Err) WithExtra(key string, value any) *Err
- func (e *Err) WithParams(params map[string]any) *Err
- func (e *Err) WithStack() *Err
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // biz error - 使用常量定义错误码 CodeBadRequest uint32 = 400 CodeInvalidArgument uint32 = 400 CodeAuth uint32 = 401 CodePermissionDenied uint32 = 403 CodeNotFound uint32 = 404 CodeAlreadyExists uint32 = 409 CodeCanceled uint32 = 499 // system error CodeInternal uint32 = 500 CodeUnknown uint32 = 500 CodeTimeout uint32 = 504 // 预定义错误类型 - 这些是模板,不应该直接修改 BadRequest = &Err{code: CodeBadRequest, message: "bad_request"} InvalidArgument = &Err{code: CodeInvalidArgument, message: "invalid_argument"} Auth = &Err{code: CodeAuth, message: "auth_failed"} PermissionDenied = &Err{code: CodePermissionDenied, message: "permission_denied"} NotFound = &Err{code: CodeNotFound, message: "not_found"} AlreadyExists = &Err{code: CodeAlreadyExists, message: "already_exists"} Canceled = &Err{code: CodeCanceled, message: "operation_canceled"} // system error Internal = &Err{code: CodeInternal, message: "internal_server_error"} Unknown = &Err{code: CodeUnknown, message: "unknown_error"} Timeout = &Err{code: CodeTimeout, message: "operation_timeout"} )
Functions ¶
This section is empty.
Types ¶
type ConnectRPCAdapter ¶
type ConnectRPCAdapter struct{}
func (*ConnectRPCAdapter) ConnectRpcAuthInterceptor ¶
func (a *ConnectRPCAdapter) ConnectRpcAuthInterceptor() connect.UnaryInterceptorFunc
func (*ConnectRPCAdapter) ToConnectCode ¶
func (a *ConnectRPCAdapter) ToConnectCode(e *Err) connect.Code
func (*ConnectRPCAdapter) ToConnectRpcError ¶
func (a *ConnectRPCAdapter) ToConnectRpcError(e *Err) *connect.Error
type Err ¶
type Err struct {
// contains filtered or unexported fields
}
func (*Err) GetUnderlyingError ¶
func (*Err) MarshalJSON ¶
Click to show internal directories.
Click to hide internal directories.