Documentation ¶
Overview ¶
nolint:gomnd
Index ¶
- Constants
- func As(err error, target any) bool
- func AsLast(err error, target any) bool
- func Code(err error) int
- func Errorf(code int, reason, format string, a ...interface{}) error
- func FromGRPCCode(code codes.Code) int
- func Is(err, target error) bool
- func IsBadRequest(err error) bool
- func IsClientClosed(err error) bool
- func IsConflict(err error) bool
- func IsForbidden(err error) bool
- func IsGatewayTimeout(err error) bool
- func IsInternalServer(err error) bool
- func IsNotFound(err error) bool
- func IsServiceUnavailable(err error) bool
- func IsUnauthorized(err error) bool
- func OK() *proto_status.Status
- func Reason(err error) string
- func ToGRPCCode(code int) codes.Code
- func Unwrap(err error) error
- type Error
- func Clone(err *Error) *Error
- func ErrorBadRequest(reason, message string) *Error
- func ErrorClientClosed(reason, message string) *Error
- func ErrorConflict(reason, message string) *Error
- func ErrorForbidden(reason, message string) *Error
- func ErrorGatewayTimeout(reason, message string) *Error
- func ErrorInternalServer(reason, message string) *Error
- func ErrorNotFound(reason, message string) *Error
- func ErrorServiceUnavailable(reason, message string) *Error
- func ErrorUnauthorized(reason, message string) *Error
- func ErrorfBadRequest(reason, format string, a ...interface{}) *Error
- func ErrorfClientClosed(reason, format string, a ...interface{}) *Error
- func ErrorfConflict(reason, format string, a ...interface{}) *Error
- func ErrorfForbidden(reason, format string, a ...interface{}) *Error
- func ErrorfGatewayTimeout(reason, format string, a ...interface{}) *Error
- func ErrorfInternalServer(reason, format string, a ...interface{}) *Error
- func ErrorfNotFound(reason, format string, a ...interface{}) *Error
- func ErrorfServiceUnavailable(reason, format string, a ...interface{}) *Error
- func ErrorfUnauthorized(reason, format string, a ...interface{}) *Error
- func FromError(err error) *Error
- func New(code int, reason, message string) *Error
- func Newf(code int, reason, format string, a ...interface{}) *Error
- type Status
Constants ¶
const ( // UnknownCode is unknown code for error info. UnknownCode = 500 // UnknownReason is unknown reason for error info. UnknownReason = "" )
const ( // StatusClientClosed is non-standard http status code, // which defined by nginx. // https://httpstatus.in/499/ StatusClientClosed = 499 )
Variables ¶
This section is empty.
Functions ¶
func As ¶
As finds the first error in err's chain that matches target, and if so, sets target to that error value and returns true.
The chain consists of err itself followed by the sequence of errors obtained by repeatedly calling Unwrap.
An error matches target if the error's concrete value is assignable to the value pointed to by target, or if the error has a method As(interface{}) bool such that As(target) returns true. In the latter case, the As method is responsible for setting target.
As will panic if target is not a non-nil pointer to either a type that implements error, or to any interface type. As returns false if err is nil.
func AsLast ¶
AsLast finds the last error in err's chain that matches target, and if so, sets target to that error value and returns true.
func FromGRPCCode ¶
FromGRPCCode converts a gRPC error code into the corresponding HTTP response status. See: https://github.com/googleapis/googleapis/blob/master/google/rpc/code.proto
func Is ¶
Is reports whether any error in err's chain matches target.
The chain consists of err itself followed by the sequence of errors obtained by repeatedly calling Unwrap.
An error is considered to match a target if it is equal to that target or if it implements a method Is(error) bool such that Is(target) returns true.
func IsBadRequest ¶
IsBadRequest determines if err is an error which indicates a BadRequest error. It supports wrapped errors.
func IsClientClosed ¶
IsClientClosed determines if err is an error which indicates a IsClientClosed error. It supports wrapped errors.
func IsConflict ¶
IsConflict determines if err is an error which indicates a Conflict error. It supports wrapped errors.
func IsForbidden ¶
IsForbidden determines if err is an error which indicates a Forbidden error. It supports wrapped errors.
func IsGatewayTimeout ¶
IsGatewayTimeout determines if err is an error which indicates a GatewayTimeout error. It supports wrapped errors.
func IsInternalServer ¶
IsInternalServer determines if err is an error which indicates an Internal error. It supports wrapped errors.
func IsNotFound ¶
IsNotFound determines if err is an error which indicates an NotFound error. It supports wrapped errors.
func IsServiceUnavailable ¶
IsServiceUnavailable determines if err is an error which indicates an Unavailable error. It supports wrapped errors.
func IsUnauthorized ¶
IsUnauthorized determines if err is an error which indicates an Unauthorized error. It supports wrapped errors.
func OK ¶
func OK() *proto_status.Status
func ToGRPCCode ¶
ToGRPCCode converts an HTTP error code into the corresponding gRPC response status. See: https://github.com/googleapis/googleapis/blob/master/google/rpc/code.proto
Types ¶
type Error ¶
type Error struct { proto_status.Status // contains filtered or unexported fields }
Error is a status error.
func ErrorBadRequest ¶
ErrorBadRequest new BadRequest error that is mapped to a 400 response.
func ErrorClientClosed ¶
ErrorClientClosed new ClientClosed error that is mapped to an HTTP 499 response.
func ErrorConflict ¶
ErrorConflict new Conflict error that is mapped to a 409 response.
func ErrorForbidden ¶
ErrorForbidden new Forbidden error that is mapped to a 403 response.
func ErrorGatewayTimeout ¶
ErrorGatewayTimeout new GatewayTimeout error that is mapped to an HTTP 504 response.
func ErrorInternalServer ¶
ErrorInternalServer new InternalServer error that is mapped to a 500 response.
func ErrorNotFound ¶
ErrorNotFound new NotFound error that is mapped to a 404 response.
func ErrorServiceUnavailable ¶
ErrorServiceUnavailable new ServiceUnavailable error that is mapped to an HTTP 503 response.
func ErrorUnauthorized ¶
ErrorUnauthorized new Unauthorized error that is mapped to a 401 response.
func ErrorfBadRequest ¶
ErrorfBadRequest New(code fmt.Sprintf(format, a...))
func ErrorfClientClosed ¶
ErrorfClientClosed New(code fmt.Sprintf(format, a...))
func ErrorfConflict ¶
ErrorfConflict New(code fmt.Sprintf(format, a...))
func ErrorfForbidden ¶
ErrorfForbidden New(code fmt.Sprintf(format, a...))
func ErrorfGatewayTimeout ¶
ErrorfGatewayTimeout New(code fmt.Sprintf(format, a...))
func ErrorfInternalServer ¶
ErrorfInternalServer New(code fmt.Sprintf(format, a...))
func ErrorfNotFound ¶
ErrorfNotFound New(code fmt.Sprintf(format, a...))
func ErrorfServiceUnavailable ¶
ErrorfServiceUnavailable New(code fmt.Sprintf(format, a...))
func ErrorfUnauthorized ¶
ErrorfUnauthorized New(code fmt.Sprintf(format, a...))
func (*Error) GRPCStatus ¶
GRPCStatus returns the Status represented by se.
func (*Error) Proto ¶
func (e *Error) Proto() *proto_status.Status
Proto returns s's status as an spb.Status proto message.