Documentation ¶
Index ¶
- Constants
- func As(err error, target interface{}) bool
- func Code(err error) codes.Code
- func Domain(err error) string
- func Errorf(code codes.Code, domain, reason, format string, a ...interface{}) error
- func Is(err, target error) bool
- func IsBadRequest(err error) bool
- func IsConflict(err error) bool
- func IsForbidden(err error) bool
- func IsInternalServer(err error) bool
- func IsNotFound(err error) bool
- func IsServiceUnavailable(err error) bool
- func IsUnauthorized(err error) bool
- func Reason(err error) string
- func Unwrap(err error) error
- type Error
- func BadRequest(domain, reason, message string) *Error
- func Conflict(domain, reason, message string) *Error
- func Forbidden(domain, reason, message string) *Error
- func FromError(err error) *Error
- func InternalServer(domain, reason, message string) *Error
- func New(code codes.Code, domain, reason, message string) *Error
- func Newf(code codes.Code, domain, reason, format string, a ...interface{}) *Error
- func NotFound(domain, reason, message string) *Error
- func ServiceUnavailable(domain, reason, message string) *Error
- func Unauthorized(domain, reason, message string) *Error
Constants ¶
const ( // SupportPackageIsVersion1 this constant should not be referenced by any other code. SupportPackageIsVersion1 = true )
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 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 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 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 a Unavailable error. It supports wrapped errors.
func IsUnauthorized ¶
IsUnauthorized determines if err is an error which indicates a Unauthorized error. It supports wrapped errors.
Types ¶
type Error ¶
type Error struct { Domain string `json:"domain"` Reason string `json:"reason"` Metadata map[string]string `json:"metadata"` // contains filtered or unexported fields }
Error is describes the cause of the error with structured details. For more details see https://github.com/googleapis/googleapis/blob/master/google/rpc/error_details.proto.
func BadRequest ¶
BadRequest new BadRequest error that is mapped to a 400 response.
func InternalServer ¶
InternalServer new InternalServer error that is mapped to a 500 response.
func ServiceUnavailable ¶
ServiceUnavailable new ServiceUnavailable error that is mapped to a HTTP 503 response.
func Unauthorized ¶
Unauthorized new Unauthorized error that is mapped to a 401 response.
func (*Error) GRPCStatus ¶
GRPCStatus returns the Status represented by se.