errors

package
v0.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 29, 2023 License: MIT Imports: 16 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
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.

View Source
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 ErrorOK

func ErrorOK() *Error

func NewErrorWithCode

func NewErrorWithCode(code ErrorCode) *Error

func NewErrorWithError

func NewErrorWithError(err error) *Error

func (*Error) Descriptor deprecated

func (*Error) Descriptor() ([]byte, []int)

Deprecated: Use Error.ProtoReflect.Descriptor instead.

func (*Error) Err

func (x *Error) Err() error

Err returns as error.

func (*Error) Error

func (x *Error) Error() string

Error is implement of error interface.

func (*Error) GetErrorCode

func (x *Error) GetErrorCode() ErrorCode

func (*Error) GetMessage

func (x *Error) GetMessage() string

func (*Error) GetReason

func (x *Error) GetReason() string

func (*Error) ProtoMessage

func (*Error) ProtoMessage()

func (*Error) ProtoReflect

func (x *Error) ProtoReflect() protoreflect.Message

func (*Error) Reset

func (x *Error) Reset()

func (*Error) String

func (x *Error) String() string

func (*Error) Success

func (x *Error) Success() bool

func (*Error) Validate

func (m *Error) Validate() error

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

func (m *Error) ValidateAll() error

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) WithError

func (x *Error) WithError(err error) *Error

func (*Error) WithMessage

func (x *Error) WithMessage(msg string) *Error

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) Enum

func (x ErrorCode) Enum() *ErrorCode

func (ErrorCode) EnumDescriptor deprecated

func (ErrorCode) EnumDescriptor() ([]byte, []int)

Deprecated: Use ErrorCode.Descriptor instead.

func (ErrorCode) Err

func (x ErrorCode) Err() error

func (ErrorCode) Err2

func (x ErrorCode) Err2() *Error

Err2 returns as Error we defined.

func (ErrorCode) Error

func (x ErrorCode) Error() string

func (ErrorCode) Number

func (x ErrorCode) Number() protoreflect.EnumNumber

func (ErrorCode) String

func (x ErrorCode) String() string

func (ErrorCode) Type

func (ErrorCode) WithError

func (x ErrorCode) WithError(err error) *Error

func (ErrorCode) WithMessage

func (x ErrorCode) WithMessage(msg string) *Error

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL