Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // 预定义错误 // Common errors Success = NewError(0, "Ok") ErrInternalServer = NewError(10000, "Internal server error") ErrInvalidParam = NewError(10001, "Invalid params") ErrNotFound = NewError(10003, "Not found") ErrUnknown = NewError(10004, "Unknown") ErrDeadlineExceeded = NewError(10005, "Deadline exceeded") ErrAccessDenied = NewError(10006, "Access denied") ErrLimitExceed = NewError(10007, "Beyond limit") ErrMethodNotAllowed = NewError(10008, "Method not allowed") ErrSignParam = NewError(10011, "Invalid sign") ErrValidation = NewError(10012, "Validation failed") ErrDatabase = NewError(10013, "Database error") ErrToken = NewError(10014, "Gen token error") ErrInvalidToken = NewError(10015, "Invalid token") ErrTokenTimeout = NewError(10016, "Token timeout") ErrTooManyRequests = NewError(10017, "Too many request") ErrInvalidTransaction = NewError(10018, "Invalid transaction") ErrEncrypt = NewError(10019, "Encrypting the user password error") )
nolint: golint
Functions ¶
func NewDetails ¶
func ToHTTPStatusCode ¶
ToHTTPStatusCode convert custom error code to http status code and avoid return unknown status code.
Types ¶
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error 返回错误码和消息的结构体 nolint: govet
func (*Error) WithDetails ¶
WithDetails return err with detail
type GrpcStatus ¶
type GrpcStatus struct {
// contains filtered or unexported fields
}
func (*GrpcStatus) WithDetails ¶
func (g *GrpcStatus) WithDetails(details ...proto.Message) *GrpcStatus
Click to show internal directories.
Click to hide internal directories.