Documentation
¶
Overview ¶
Example (ErrorsUsage) ¶
package main
import (
"fmt"
"git.corout.in/golibs/fields"
"git.corout.in/golibs/slog"
"git.corout.in/golibs/slog/zaplogger"
"git.corout.in/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)
}
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 ...interface{}) 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 ...interface{}) 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 ¶ added in v1.1.0
func RecoverError(reason interface{}) error
Types ¶
type Chain ¶
type Chain []error
Chain - цепочка ошибок
type Const ¶
type Const string
Const - тип используемый для константных ошибок, позволяет избегать возможных мутаций значений ошибок.
type ContextError ¶ added in v1.1.0
type ContextError interface {
Just(err error) error
New(reason string) error
Newf(format string, args ...interface{}) error
Wrap(err error, reason string) error
Wrapf(err error, format string, args ...interface{}) 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 ¶ added in v1.1.0
func Ctx() ContextError
Ctx - конструтор контекстной ошибки для определния полей в блоках условий для последующей обертки или формирования как есть
type ErrRecover ¶ added in v1.1.0
type ErrRecover struct {
// contains filtered or unexported fields
}
func (ErrRecover) Error ¶ added in v1.1.0
func (e ErrRecover) Error() string
type FormattedError ¶ added in v1.1.0
type FormattedError struct {
// contains filtered or unexported fields
}
FormattedError форматированная ошибка для вывода в результатах тестов
func (*FormattedError) Any ¶ added in v1.1.0
func (f *FormattedError) Any(key string, value interface{})
func (*FormattedError) Bool ¶ added in v1.1.0
func (f *FormattedError) Bool(key string, value bool)
func (*FormattedError) Error ¶ added in v1.1.0
func (f *FormattedError) Error() string
func (*FormattedError) Float32 ¶ added in v1.1.0
func (f *FormattedError) Float32(key string, value float32)
func (*FormattedError) Float64 ¶ added in v1.1.0
func (f *FormattedError) Float64(key string, value float64)
func (*FormattedError) Int ¶ added in v1.1.0
func (f *FormattedError) Int(key string, value int)
func (*FormattedError) Int16 ¶ added in v1.1.0
func (f *FormattedError) Int16(key string, value int16)
func (*FormattedError) Int32 ¶ added in v1.1.0
func (f *FormattedError) Int32(key string, value int32)
func (*FormattedError) Int64 ¶ added in v1.1.0
func (f *FormattedError) Int64(key string, value int64)
func (*FormattedError) Int8 ¶ added in v1.1.0
func (f *FormattedError) Int8(key string, value int8)
func (*FormattedError) Str ¶ added in v1.1.0
func (f *FormattedError) Str(key, value string)
func (*FormattedError) Strings ¶ added in v1.1.0
func (f *FormattedError) Strings(key string, values []string)
func (*FormattedError) Uint ¶ added in v1.1.0
func (f *FormattedError) Uint(key string, value uint)
func (*FormattedError) Uint16 ¶ added in v1.1.0
func (f *FormattedError) Uint16(key string, value uint16)
func (*FormattedError) Uint32 ¶ added in v1.1.0
func (f *FormattedError) Uint32(key string, value uint32)
func (*FormattedError) Uint64 ¶ added in v1.1.0
func (f *FormattedError) Uint64(key string, value uint64)
func (*FormattedError) Uint8 ¶ added in v1.1.0
func (f *FormattedError) Uint8(key string, value uint8)
Source Files
¶
Click to show internal directories.
Click to hide internal directories.