Documentation
¶
Index ¶
- Constants
- Variables
- type Error
- type ErrorV2
- func (e *ErrorV2) Code() int
- func (e *ErrorV2) Equal(code int, reason ...string) bool
- func (e *ErrorV2) Error() string
- func (e *ErrorV2) GRPCStatus() *status.Status
- func (e *ErrorV2) Is(err error) bool
- func (e *ErrorV2) Message() string
- func (e *ErrorV2) Reason() string
- func (e *ErrorV2) Unwrap() error
- func (e *ErrorV2) WithCause(cause error) *ErrorV2
- func (e *ErrorV2) WithMetadata(md map[string]string) *ErrorV2
- type Status
- func (*Status) Descriptor() ([]byte, []int)deprecated
- func (x *Status) GetCode() int32
- func (x *Status) GetMessage() string
- func (x *Status) GetMetadata() map[string]string
- func (x *Status) GetReason() string
- func (*Status) ProtoMessage()
- func (x *Status) ProtoReflect() protoreflect.Message
- func (x *Status) Reset()
- func (x *Status) String() string
Constants ¶
View Source
const ( // UnknownCode is unknown code for error info. UnknownCode = http.StatusInternalServerError // UnknownReason is unknown reason for error info. UnknownReason = "" // ClientClosed is non-standard http status code, // which defined by nginx. // https://httpstatus.in/499/ ClientClosed = 499 )
Variables ¶
View Source
var ( // base error Success = NewV2(http.StatusOK, "SUCCESS", "success") RequestErr = NewV2(http.StatusBadRequest, "PARAM_ERROR", "request param error") ForbiddenErr = NewV2(http.StatusForbidden, "NO_AUTH", "no auth") NotFoundErr = NewV2(http.StatusNotFound, "RESOURCE_NOT_FOUND", "resource not found") TooManyRequestErr = NewV2(http.StatusTooManyRequests, "RATELIMIT_EXCEEDED", "ratelimit exceeded") ServerErr = NewV2(http.StatusInternalServerError, "SERVER_ERROR", "server error") BadGatewayErr = NewV2(http.StatusBadGateway, "SERVICE_UNAVAILABLE", "service offline, unavailable") )
View Source
var DefaultConverter = statusConverter{}
DefaultConverter default converter.
View Source
var File_ecode_errors_proto protoreflect.FileDescriptor
Functions ¶
This section is empty.
Types ¶
type Error ¶ added in v1.0.16
type Error struct {
// contains filtered or unexported fields
}
Error struct
func (*Error) GRPCStatus ¶ added in v1.0.16
type ErrorV2 ¶ added in v1.0.18
type ErrorV2 struct {
Status
// contains filtered or unexported fields
}
ErrorV2 struct
func FromError ¶ added in v1.0.16
FromError try to convert an error to *ErrorV2. It supports wrapped errors.
func (*ErrorV2) GRPCStatus ¶ added in v1.0.18
GRPCStatus returns the Status represented by error.
type Status ¶ added in v1.0.16
type Status struct {
Code int32 `protobuf:"varint,1,opt,name=code,proto3" json:"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"`
Metadata map[string]string `` /* 157-byte string literal not displayed */
// contains filtered or unexported fields
}
func (*Status) Descriptor
deprecated
added in
v1.0.16
func (*Status) GetMessage ¶ added in v1.0.16
func (*Status) GetMetadata ¶ added in v1.0.16
func (*Status) ProtoMessage ¶ added in v1.0.16
func (*Status) ProtoMessage()
func (*Status) ProtoReflect ¶ added in v1.0.16
func (x *Status) ProtoReflect() protoreflect.Message
Click to show internal directories.
Click to hide internal directories.