Documentation
¶
Index ¶
- type ErrorNum
- type ErrorNumEntry
- func (e ErrorNumEntry) Context() context.Context
- func (e ErrorNumEntry) GetCode() int
- func (e ErrorNumEntry) GetError() error
- func (e ErrorNumEntry) GetHttpCode() int
- func (e ErrorNumEntry) GetMsg() string
- func (e ErrorNumEntry) WithCode(code int) ErrorNum
- func (e ErrorNumEntry) WithContext(ctx context.Context) ErrorNum
- func (e ErrorNumEntry) WithError(err error) ErrorNum
- func (e ErrorNumEntry) WithHttpCode(code int) ErrorNum
- func (e ErrorNumEntry) WithMsg(desc string) ErrorNum
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrorNum ¶
type ErrorNum interface { WithError(err error) ErrorNum GetError() error WithContext(ctx context.Context) ErrorNum Context() context.Context WithCode(code int) ErrorNum GetCode() int WithMsg(desc string) ErrorNum GetMsg() string WithHttpCode(code int) ErrorNum GetHttpCode() int }
var ( IllegalParam ErrorNum = ErrorNumEntry{ HttpCode: http.StatusBadRequest, Code: 400, Msg: "illegal parameter", } HttpCode: http.StatusUnauthorized, Code: 401, Msg: "unauthorized", } Success ErrorNum = ErrorNumEntry{ HttpCode: http.StatusOK, Code: 200, Msg: "success", } Forbidden ErrorNum = ErrorNumEntry{ HttpCode: http.StatusForbidden, Code: 403, Msg: "forbidden", } ErrorExecuteFunc ErrorNum = ErrorNumEntry{ HttpCode: http.StatusBadRequest, Code: 500, Msg: "execute func error", } ErrorGrpcConnect ErrorNum = ErrorNumEntry{ HttpCode: http.StatusInternalServerError, Code: 500, Msg: "grpc connect error", } )
type ErrorNumEntry ¶
type ErrorNumEntry struct { Code int // 业务码 Msg string // 美化描述 HttpCode int // contains filtered or unexported fields }
func NewError ¶ added in v0.0.7
func NewError(code int, msg string) ErrorNumEntry
func NewErrorFromGrpcStatus ¶ added in v0.0.7
func NewErrorFromGrpcStatus(s *status.Status) ErrorNumEntry
func (ErrorNumEntry) Context ¶
func (e ErrorNumEntry) Context() context.Context
func (ErrorNumEntry) GetCode ¶
func (e ErrorNumEntry) GetCode() int
func (ErrorNumEntry) GetError ¶
func (e ErrorNumEntry) GetError() error
func (ErrorNumEntry) GetHttpCode ¶
func (e ErrorNumEntry) GetHttpCode() int
func (ErrorNumEntry) GetMsg ¶
func (e ErrorNumEntry) GetMsg() string
func (ErrorNumEntry) WithCode ¶
func (e ErrorNumEntry) WithCode(code int) ErrorNum
func (ErrorNumEntry) WithContext ¶
func (e ErrorNumEntry) WithContext(ctx context.Context) ErrorNum
func (ErrorNumEntry) WithError ¶
func (e ErrorNumEntry) WithError(err error) ErrorNum
func (ErrorNumEntry) WithHttpCode ¶
func (e ErrorNumEntry) WithHttpCode(code int) ErrorNum
func (ErrorNumEntry) WithMsg ¶
func (e ErrorNumEntry) WithMsg(desc string) ErrorNum
Click to show internal directories.
Click to hide internal directories.