Documentation
¶
Overview ¶
Package xerrors 提供标准化错误处理工具。
Index ¶
- Variables
- func Combine(errs ...error) error
- func GetCode(err error) string
- func Must[T any](v T, err error) T
- func MustOK[T any](v T, ok bool) T
- func WithCode(err error, code string) error
- func Wrap(err error, msg string) error
- func Wrapf(err error, format string, args ...any) error
- type CodedError
- type Collector
- type MultiError
Constants ¶
This section is empty.
Variables ¶
View Source
var ( New = errors.New Is = errors.Is As = errors.As Unwrap = errors.Unwrap Join = errors.Join )
标准库函数再导出
Functions ¶
Types ¶
type CodedError ¶
CodedError 带有机器可读错误码的错误。
func (*CodedError) Error ¶
func (e *CodedError) Error() string
func (*CodedError) Unwrap ¶
func (e *CodedError) Unwrap() error
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
Collector 收集多个错误,保留第一个。
type MultiError ¶
type MultiError struct {
Errors []error
}
MultiError 合并多个错误。
func (*MultiError) Error ¶
func (m *MultiError) Error() string
func (*MultiError) Unwrap ¶
func (m *MultiError) Unwrap() []error
Click to show internal directories.
Click to hide internal directories.