Documentation ¶
Index ¶
- Variables
- type Error
- func (*Error) Descriptor() ([]byte, []int)deprecated
- func (x *Error) Err() error
- func (x *Error) Error() string
- func (x *Error) GetErrorCode() ErrorCode
- func (x *Error) GetMessage() string
- func (x *Error) GetReason() string
- func (*Error) ProtoMessage()
- func (x *Error) ProtoReflect() protoreflect.Message
- func (x *Error) Reset()
- func (x *Error) String() string
- func (x *Error) Success() bool
- func (m *Error) Validate() error
- func (m *Error) ValidateAll() error
- func (x *Error) WithError(err error) *Error
- func (x *Error) WithMessage(msg string) *Error
- type ErrorCode
- func (ErrorCode) Descriptor() protoreflect.EnumDescriptor
- func (x ErrorCode) Enum() *ErrorCode
- func (ErrorCode) EnumDescriptor() ([]byte, []int)deprecated
- func (x ErrorCode) Err() error
- func (x ErrorCode) Err2() *Error
- func (x ErrorCode) Error() string
- func (x ErrorCode) Number() protoreflect.EnumNumber
- func (x ErrorCode) String() string
- func (ErrorCode) Type() protoreflect.EnumType
- func (x ErrorCode) WithError(err error) *Error
- func (x ErrorCode) WithMessage(msg string) *Error
- type ErrorMultiError
- type ErrorValidationError
Constants ¶
This section is empty.
Variables ¶
var ( ErrorCode_name = map[int32]string{ 0: "OK", 10001: "InternalError", 10002: "InvalidParams", 10003: "DBError", 10004: "CacheError", 20001: "UserNotExist", 20002: "UserExist", 20003: "InvalidUsernameOrPassword", 30001: "RelationNotExist", 30002: "RelationExist", 30003: "InvalidUpdateRelationAction", 31001: "FriendRequestNotExist", 31002: "FriendRequestStatusError", 40001: "UserNotOnline", 50001: "GroupNotExist", 50002: "GroupExist", 50003: "NotGroupMember", 50004: "NotGroupOwner", 50005: "GroupLimitExceed", } ErrorCode_value = map[string]int32{ "OK": 0, "InternalError": 10001, "InvalidParams": 10002, "DBError": 10003, "CacheError": 10004, "UserNotExist": 20001, "UserExist": 20002, "InvalidUsernameOrPassword": 20003, "RelationNotExist": 30001, "RelationExist": 30002, "InvalidUpdateRelationAction": 30003, "FriendRequestNotExist": 31001, "FriendRequestStatusError": 31002, "UserNotOnline": 40001, "GroupNotExist": 50001, "GroupExist": 50002, "NotGroupMember": 50003, "NotGroupOwner": 50004, "GroupLimitExceed": 50005, } )
Enum value maps for ErrorCode.
var File_errors_errors_proto protoreflect.FileDescriptor
Functions ¶
This section is empty.
Types ¶
type Error ¶
type Error struct { ErrorCode ErrorCode `protobuf:"varint,1,opt,name=error_code,json=errorCode,proto3,enum=api.errors.ErrorCode" json:"error_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"` // contains filtered or unexported fields }
Error use as define error code and message.
func NewErrorWithCode ¶
func NewErrorWithError ¶
func (*Error) Descriptor
deprecated
func (*Error) GetErrorCode ¶
func (*Error) GetMessage ¶
func (*Error) ProtoMessage ¶
func (*Error) ProtoMessage()
func (*Error) ProtoReflect ¶
func (x *Error) ProtoReflect() protoreflect.Message
func (*Error) Validate ¶
Validate checks the field values on Error with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.
func (*Error) ValidateAll ¶
ValidateAll checks the field values on Error with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in ErrorMultiError, or nil if none found.
func (*Error) WithMessage ¶
type ErrorCode ¶
type ErrorCode int32
const ( ErrorCode_OK ErrorCode = 0 // common error codes ErrorCode_InternalError ErrorCode = 10001 ErrorCode_InvalidParams ErrorCode = 10002 ErrorCode_DBError ErrorCode = 10003 ErrorCode_CacheError ErrorCode = 10004 // user error codes ErrorCode_UserNotExist ErrorCode = 20001 ErrorCode_UserExist ErrorCode = 20002 ErrorCode_InvalidUsernameOrPassword ErrorCode = 20003 // relation error codes ErrorCode_RelationNotExist ErrorCode = 30001 ErrorCode_RelationExist ErrorCode = 30002 ErrorCode_InvalidUpdateRelationAction ErrorCode = 30003 // friend request error codes ErrorCode_FriendRequestNotExist ErrorCode = 31001 ErrorCode_FriendRequestStatusError ErrorCode = 31002 // push server error codes ErrorCode_UserNotOnline ErrorCode = 40001 // group error codes ErrorCode_GroupNotExist ErrorCode = 50001 ErrorCode_GroupExist ErrorCode = 50002 ErrorCode_NotGroupMember ErrorCode = 50003 ErrorCode_NotGroupOwner ErrorCode = 50004 ErrorCode_GroupLimitExceed ErrorCode = 50005 )
func (ErrorCode) Descriptor ¶
func (ErrorCode) Descriptor() protoreflect.EnumDescriptor
func (ErrorCode) EnumDescriptor
deprecated
func (ErrorCode) Number ¶
func (x ErrorCode) Number() protoreflect.EnumNumber
func (ErrorCode) Type ¶
func (ErrorCode) Type() protoreflect.EnumType
func (ErrorCode) WithMessage ¶
type ErrorMultiError ¶
type ErrorMultiError []error
ErrorMultiError is an error wrapping multiple validation errors returned by Error.ValidateAll() if the designated constraints aren't met.
func (ErrorMultiError) AllErrors ¶
func (m ErrorMultiError) AllErrors() []error
AllErrors returns a list of validation violation errors.
func (ErrorMultiError) Error ¶
func (m ErrorMultiError) Error() string
Error returns a concatenation of all the error messages it wraps.
type ErrorValidationError ¶
type ErrorValidationError struct {
// contains filtered or unexported fields
}
ErrorValidationError is the validation error returned by Error.Validate if the designated constraints aren't met.
func (ErrorValidationError) Cause ¶
func (e ErrorValidationError) Cause() error
Cause function returns cause value.
func (ErrorValidationError) Error ¶
func (e ErrorValidationError) Error() string
Error satisfies the builtin error interface
func (ErrorValidationError) ErrorName ¶
func (e ErrorValidationError) ErrorName() string
ErrorName returns error name.
func (ErrorValidationError) Field ¶
func (e ErrorValidationError) Field() string
Field function returns field value.
func (ErrorValidationError) Key ¶
func (e ErrorValidationError) Key() bool
Key function returns key value.
func (ErrorValidationError) Reason ¶
func (e ErrorValidationError) Reason() string
Reason function returns reason value.