Documentation ¶
Overview ¶
Example (ErrorsUsage) ¶
package main import ( "fmt" "git.eth4.dev/golibs/fields" "git.eth4.dev/golibs/slog" "git.eth4.dev/golibs/slog/zaplogger" "git.eth4.dev/golibs/errors" ) func main() { err := fmt.Errorf("Some error") err = errors.Ctx(). Int("test-int-key", 10). Str("test-str-key", "blah-blah"). Just(err) log := zaplogger.New(slog.DebugLevel, true) log.Error("Test error", err) log.Errorf("Test error with arg: %s", "test arg", err) log.Error( "Test error with additional fields", fields.Str("additional", "field"), fields.Bool("is_worked", true), err, ) err = errors.Wrap(err, "test wrap wrapped error") log.Error("Have new wrapped error", err) err = errors.Ctx().Str("injecting", "this some injecting on next level").Just(err) log.Error("Next level injected fields", err) }
Output:
Index ¶
- func And(err1, err2 error) error
- func As(err error, target interface{}) bool
- func Extract(err error) []fields.Field
- func Formatted(err error, args ...any) error
- func Is(err, target error) bool
- func New(reason string) error
- func RecoverError(reason interface{}) error
- func Wrap(err error, message string) error
- func Wrapf(err error, format string, args ...any) error
- type Chain
- type Const
- type ContextError
- type ErrRecover
- type FormattedError
- func (f *FormattedError) Any(key string, value interface{})
- func (f *FormattedError) Bool(key string, value bool)
- func (f *FormattedError) Error() string
- func (f *FormattedError) Float32(key string, value float32)
- func (f *FormattedError) Float64(key string, value float64)
- func (f *FormattedError) Int(key string, value int)
- func (f *FormattedError) Int16(key string, value int16)
- func (f *FormattedError) Int32(key string, value int32)
- func (f *FormattedError) Int64(key string, value int64)
- func (f *FormattedError) Int8(key string, value int8)
- func (f *FormattedError) Str(key, value string)
- func (f *FormattedError) Strings(key string, values []string)
- func (f *FormattedError) Uint(key string, value uint)
- func (f *FormattedError) Uint16(key string, value uint16)
- func (f *FormattedError) Uint32(key string, value uint32)
- func (f *FormattedError) Uint64(key string, value uint64)
- func (f *FormattedError) Uint8(key string, value uint8)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RecoverError ¶
func RecoverError(reason interface{}) error
Types ¶
type Chain ¶
type Chain []error
Chain - цепочка ошибок
type Const ¶
type Const string
Const - тип используемый для константных ошибок, позволяет избегать возможных мутаций значений ошибок.
type ContextError ¶
type ContextError interface { Just(err error) error New(reason string) error Newf(format string, args ...any) error Wrap(err error, reason string) error Wrapf(err error, format string, args ...any) error With(flds ...fields.Field) ContextError Pos(depth int) ContextError Bool(key string, value bool) ContextError Int(key string, value int) ContextError Int8(key string, value int8) ContextError Int16(key string, value int16) ContextError Int32(key string, value int32) ContextError Int64(key string, value int64) ContextError Uint(key string, value uint) ContextError Uint8(key string, value uint8) ContextError Uint16(key string, value uint16) ContextError Uint32(key string, value uint32) ContextError Uint64(key string, value uint64) ContextError Float32(key string, value float32) ContextError Float64(key string, value float64) ContextError Str(key string, value string) ContextError Strings(key string, values []string) ContextError Stringer(key string, value fmt.Stringer) ContextError Any(key string, value interface{}) ContextError WithStack() ContextError Extract(out fields.FieldExtractor) }
ContextError - интерфейс контекстной (анотированной полями) ошибки
func Ctx ¶
func Ctx() ContextError
Ctx - конструтор контекстной ошибки для определния полей в блоках условий для последующей обертки или формирования как есть
type ErrRecover ¶
type ErrRecover struct {
// contains filtered or unexported fields
}
func (ErrRecover) Error ¶
func (e ErrRecover) Error() string
type FormattedError ¶
type FormattedError struct {
// contains filtered or unexported fields
}
FormattedError форматированная ошибка для вывода в результатах тестов
func (*FormattedError) Any ¶
func (f *FormattedError) Any(key string, value interface{})
func (*FormattedError) Bool ¶
func (f *FormattedError) Bool(key string, value bool)
func (*FormattedError) Error ¶
func (f *FormattedError) Error() string
func (*FormattedError) Float32 ¶
func (f *FormattedError) Float32(key string, value float32)
func (*FormattedError) Float64 ¶
func (f *FormattedError) Float64(key string, value float64)
func (*FormattedError) Int ¶
func (f *FormattedError) Int(key string, value int)
func (*FormattedError) Int16 ¶
func (f *FormattedError) Int16(key string, value int16)
func (*FormattedError) Int32 ¶
func (f *FormattedError) Int32(key string, value int32)
func (*FormattedError) Int64 ¶
func (f *FormattedError) Int64(key string, value int64)
func (*FormattedError) Int8 ¶
func (f *FormattedError) Int8(key string, value int8)
func (*FormattedError) Str ¶
func (f *FormattedError) Str(key, value string)
func (*FormattedError) Strings ¶
func (f *FormattedError) Strings(key string, values []string)
func (*FormattedError) Uint ¶
func (f *FormattedError) Uint(key string, value uint)
func (*FormattedError) Uint16 ¶
func (f *FormattedError) Uint16(key string, value uint16)
func (*FormattedError) Uint32 ¶
func (f *FormattedError) Uint32(key string, value uint32)
func (*FormattedError) Uint64 ¶
func (f *FormattedError) Uint64(key string, value uint64)
func (*FormattedError) Uint8 ¶
func (f *FormattedError) Uint8(key string, value uint8)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.