Documentation ¶
Overview ¶
Package errors provides a way to return detailed information for an RPC request error. The error is normally JSON encoded.
Index ¶
- Constants
- Variables
- func Equal(err1 error, err2 error) bool
- func New(id, domain string, code ErrorCoder) error
- type Error
- func (*Error) Descriptor() ([]byte, []int)deprecated
- func (e *Error) Error() string
- func (x *Error) GetDomain() string
- func (x *Error) GetErrorCode() string
- func (x *Error) GetErrorMessage() string
- func (x *Error) GetShowType() string
- func (x *Error) GetSuccess() bool
- func (x *Error) GetTraceId() string
- func (*Error) ProtoMessage()
- func (x *Error) ProtoReflect() protoreflect.Message
- func (x *Error) Reset()
- func (x *Error) String() string
- type ErrorCode
- type ErrorCoder
Constants ¶
View Source
const ( Silent = "0" MessageWarn = "1" MessageError = "2" Notification = "4" Page = "9" )
Variables ¶
View Source
var File_errors_proto protoreflect.FileDescriptor
Functions ¶
Types ¶
type Error ¶
type Error struct { // Success if request is success Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` // ErrorCode code for errorType ErrorCode string `protobuf:"bytes,2,opt,name=errorCode,proto3" json:"errorCode,omitempty"` // ErrorMessage message display to user ErrorMessage string `protobuf:"bytes,3,opt,name=errorMessage,proto3" json:"errorMessage,omitempty"` // ShowType error display type: 0 silent; 1 message.warn; 2 message.error; 4 notification; 9 page ShowType string `protobuf:"bytes,4,opt,name=showType,proto3" json:"showType,omitempty"` // TraceId Convenient for back-end Troubleshooting: unique request ID TraceId string `protobuf:"bytes,5,opt,name=traceId,proto3" json:"traceId,omitempty"` // Domain onvenient for backend Troubleshooting: host of current access server Domain string `protobuf:"bytes,6,opt,name=domain,proto3" json:"domain,omitempty"` // contains filtered or unexported fields }
func Parse ¶
Parse tries to parse a JSON string into an error. If that fails, it will set the given string as the error detail.
func (*Error) Descriptor
deprecated
func (*Error) GetErrorCode ¶ added in v1.3.6
func (*Error) GetErrorMessage ¶ added in v1.3.6
func (*Error) GetShowType ¶ added in v1.3.6
func (*Error) GetSuccess ¶ added in v1.3.6
func (*Error) GetTraceId ¶ added in v1.3.6
func (*Error) ProtoMessage ¶
func (*Error) ProtoMessage()
func (*Error) ProtoReflect ¶
func (x *Error) ProtoReflect() protoreflect.Message
type ErrorCode ¶
type ErrorCode int32
const ( OK ErrorCode = http.StatusOK BadRequest ErrorCode = http.StatusBadRequest Forbidden ErrorCode = http.StatusForbidden NotFound ErrorCode = http.StatusNotFound MethodNotAllowed ErrorCode = http.StatusMethodNotAllowed Timeout ErrorCode = http.StatusRequestTimeout Conflict ErrorCode = http.StatusConflict InternalServerError ErrorCode = http.StatusInternalServerError )
Click to show internal directories.
Click to hide internal directories.