Documentation ¶
Overview ¶
Package errors defines some error types and provides functions to identify the type of specified error.
Index ¶
- func As(err error, target any) bool
- func Is(err, target error) bool
- func IsConnectionError(err error) bool
- func IsFileError(err error) bool
- func IsProtoBufError(err error) bool
- func IsTimeoutError(err error) bool
- func IsUnacceptableResponseError(err error) bool
- func Join(errs ...error) error
- func New(msg string) error
- func Unwrap(err error) error
- type ProtoBufError
- type UnacceptableResponseError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsConnectionError ¶
IsConnectionError reports whether the specified error is encountered during sending an HTTP request and receiving the response.
func IsFileError ¶
IsFileError reports whether the specified error is caused by operating a file or file path.
func IsProtoBufError ¶
IsProtoBufError reports whether the specified error is encountered during reading or writing ProtoBuf messages.
func IsTimeoutError ¶
IsTimeoutError reports whether the specified error is caused by a timeout.
func IsUnacceptableResponseError ¶
IsUnacceptableResponseError reports whether the specified error is caused by an unacceptable HTTP response.
Types ¶
type ProtoBufError ¶
type ProtoBufError struct { Op string // Op is the name of the operation that caused the error. Type string // Type is the type name of the operand. Err error // Err is the error reading or writing ProtoBuf messages. }
ProtoBufError records an error reading or writing ProtoBuf messages and the operation that caused it.
func NewProtoBufError ¶
func NewProtoBufError(Op string, v any, err error) *ProtoBufError
NewProtoBufError creates a new *ProtoBufError.
It records the specified operation name (Op) and error (err).
It records the type name according to v. If v is nil, it records the type name as "<nil>". If v is an interface or a pointer, and v is non-nil, it repeatedly replaces v with the element of v (i.e., the value that the interface v contains or that the pointer v points to) until v is neither an interface nor a pointer or v is nil. Otherwise, it records the type name of v.
func (*ProtoBufError) Error ¶
func (e *ProtoBufError) Error() string
func (*ProtoBufError) Unwrap ¶
func (e *ProtoBufError) Unwrap() error
type UnacceptableResponseError ¶
type UnacceptableResponseError struct { StatusCode int // StatusCode is the status code of the response, set only if unexpected. Status string // Status is the status of the response, set only if unexpected. ReadError error // ReadError is the error reading the response body. Body string // Body is the body of the response. // WantBody is the expected body of the response, // set only if no error occurs when reading the response body. WantBody string }
UnacceptableResponseError records an unacceptable HTTP response, including unexpected response status, errors reading the response body, and unexpected response body.
func (*UnacceptableResponseError) Error ¶
func (e *UnacceptableResponseError) Error() string
func (*UnacceptableResponseError) Unwrap ¶
func (e *UnacceptableResponseError) Unwrap() error
Unwrap returns the error reading the response body.