Documentation
¶
Index ¶
- Constants
- Variables
- type Error
- func (e *Error) Code() int
- func (e *Error) Equal(code int, reason ...string) bool
- func (e *Error) Error() string
- func (e *Error) GRPCStatus() *status.Status
- func (e *Error) Is(err error) bool
- func (e *Error) Message() string
- func (e *Error) Reason() string
- func (e *Error) Unwrap() error
- func (e *Error) WithCause(cause error) *Error
- func (e *Error) WithMetadata(md map[string]string) *Error
- 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 = New(http.StatusOK, "SUCCESS", "success") RequestErr = New(http.StatusBadRequest, "PARAM_ERROR", "request param error") ForbiddenErr = New(http.StatusForbidden, "NO_AUTH", "no auth") NotFoundErr = New(http.StatusNotFound, "RESOURCE_NOT_FOUND", "resource not found") TooManyRequestErr = New(http.StatusTooManyRequests, "RATELIMIT_EXCEEDED", "ratelimit exceeded") ServerErr = New(http.StatusInternalServerError, "SERVER_ERROR", "server error") BadGatewayErr = New(http.StatusBadGateway, "SERVICE_UNAVAILABLE", "service offline, unavailable") )
View Source
var DefaultConverter = statusConverter{}
DefaultConverter default converter.
View Source
var File_errors_proto protoreflect.FileDescriptor
Functions ¶
This section is empty.
Types ¶
type Error ¶
type Error struct { Status // contains filtered or unexported fields }
Error struct
func (*Error) GRPCStatus ¶
GRPCStatus returns the Status represented by error.
type Status ¶
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
func (*Status) GetMessage ¶
func (*Status) GetMetadata ¶
func (*Status) ProtoMessage ¶
func (*Status) ProtoMessage()
func (*Status) ProtoReflect ¶
func (x *Status) ProtoReflect() protoreflect.Message
Click to show internal directories.
Click to hide internal directories.