From 4cf36282e62f126ba6fb378d33a6132f04124098 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Mon, 21 Oct 2024 01:08:28 +0300 Subject: [PATCH] [errors] Added new package of utilities for working with errors --- .scripts/packages.list | 1 + CHANGELOG.md | 4 +- README.md | 2 +- errors/errors.go | 274 ++++++++++++++++++++++++++++++++++++ errors/errors_test.go | 200 +++++++++++++++++++++++++++ errors/example_test.go | 307 +++++++++++++++++++++++++++++++++++++++++ errutil/errutil.go | 28 ++++ version.go | 2 +- 8 files changed, 815 insertions(+), 3 deletions(-) create mode 100644 errors/errors.go create mode 100644 errors/errors_test.go create mode 100644 errors/example_test.go diff --git a/.scripts/packages.list b/.scripts/packages.list index d3aeb400..be1f19a1 100644 --- a/.scripts/packages.list +++ b/.scripts/packages.list @@ -9,6 +9,7 @@ * + emoji * + env * + errutil +* + errors * + events * + fmtc * + fmtutil diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ffa3ea9..72498b3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,10 @@ ## Changelog -### [13.8.2](https://kaos.sh/ek/13.8.2) +### [13.9.0](https://kaos.sh/ek/13.9.0) +- `[errors]` Added new package of utilities for working with errors - `[knf]` Added type `Validators` for `Validator` slice +- `[errutil]` Package deprecated ### [13.8.1](https://kaos.sh/ek/13.8.1) diff --git a/README.md b/README.md index fc72f5c9..ea321b2a 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Currently we support Linux and macOS (_except some packages_). All packages have - [`easing`](https://kaos.sh/g/ek.v13/easing) — Package with easing functions (_Back, Bounce, Circ, Cubic, Elastic, Expo, Linear, Quad, Quint, Sine_) - [`emoji`](https://kaos.sh/g/ek.v13/emoji) — Package provides methods for working with emojis - [`env`](https://kaos.sh/g/ek.v13/env) — Package provides methods for working with environment variables -- [`errutil`](https://kaos.sh/g/ek.v13/errutil) — Package provides methods for working with errors +- [`errors`](https://kaos.sh/g/ek.v13/errors) — Package provides methods for working with errors - [`events`](https://kaos.sh/g/ek.v13/events) — Package provides methods and structs for creating event-driven systems - [`directio`](https://kaos.sh/g/ek.v13/directio) — Package provides methods for reading/writing files with direct io - [`fmtc`](https://kaos.sh/g/ek.v13/fmtc) — Package provides methods similar to fmt for colored output ([_more info and examples_](fmtc/README.md)) diff --git a/errors/errors.go b/errors/errors.go new file mode 100644 index 00000000..42837c36 --- /dev/null +++ b/errors/errors.go @@ -0,0 +1,274 @@ +// Package errutil provides methods for working with errors +package errors + +// ////////////////////////////////////////////////////////////////////////////////// // +// // +// Copyright (c) 2024 ESSENTIAL KAOS // +// Apache License, Version 2.0 // +// // +// ////////////////////////////////////////////////////////////////////////////////// // + +import ( + "errors" + "strings" +) + +// ////////////////////////////////////////////////////////////////////////////////// // + +// Errors is a slice with errors +type Errors []error + +// Bundle is a bundle of errors +type Bundle struct { + capacity int + errors Errors +} + +// ////////////////////////////////////////////////////////////////////////////////// // + +// New returns an error that formats as the given text. Each call to New returns +// a distinct error value even if the text is identical. +func New(text string) error { + return errors.New(text) +} + +// Is reports whether any error in err's tree matches target +func Is(err, target error) bool { + return errors.Is(err, target) +} + +// As finds the first error in err's tree that matches target, and if one is found, +// sets target to that error value and returns true. Otherwise, it returns false. +func As(err error, target any) bool { + return errors.As(err, target) +} + +// Join returns an error that wraps the given errors +func Join(errs ...error) error { + return errors.Join(errs...) +} + +// Unwrap returns the result of calling the Unwrap method on err, if err's type contains +// an Unwrap method returning error. Otherwise, Unwrap returns nil. +func Unwrap(err error) error { + return errors.Unwrap(err) +} + +// ////////////////////////////////////////////////////////////////////////////////// // + +// NewBundle creates new errors bundle +func NewBundle(capacity ...int) *Bundle { + if len(capacity) == 0 { + return &Bundle{} + } + + size := capacity[0] + + if size < 0 { + size = 0 + } + + return &Bundle{capacity: size} +} + +// ToBundle wraps slice of errors into Bundle +func ToBundle(errs Errors) *Bundle { + return &Bundle{errors: errs} +} + +// Chain executes functions in chain and if one of them returns an error, this function +// stops the chain execution and returns that error +func Chain(funcs ...func() error) error { + var err error + + for _, chainFunc := range funcs { + err = chainFunc() + + if err != nil { + return err + } + } + + return err +} + +// ////////////////////////////////////////////////////////////////////////////////// // + +// Last returns the first error from the slice +func (e Errors) First() error { + if e.IsEmpty() { + return nil + } + + return e[0] +} + +// Last returns the last error from the slice +func (e Errors) Last() error { + if e.IsEmpty() { + return nil + } + + return e[e.Num()-1] +} + +// Get returns error with given index +func (e Errors) Get(index int) error { + if index < 0 || index >= len(e) { + return nil + } + + return e[index] +} + +// IsEmpty returns true if slice is empty +func (e Errors) IsEmpty() bool { + return len(e) == 0 +} + +// Num returns size of the slice +func (e Errors) Num() int { + return len(e) +} + +// Error returns combined text of all errors in the slice +func (e Errors) Error(prefix string) string { + var buf strings.Builder + + for _, err := range e { + buf.WriteString(prefix) + buf.WriteString(err.Error()) + buf.WriteRune('\n') + } + + return buf.String() +} + +// ////////////////////////////////////////////////////////////////////////////////// // + +// Add adds new error to slice +func (b *Bundle) Add(errs ...any) *Bundle { + if errs == nil { + return b + } + + for _, err := range errs { + switch v := err.(type) { + case *Bundle: + if v != nil && len(v.errors) > 0 { + b.errors = append(b.errors, v.errors...) + } + + case Bundle: + if len(v.errors) > 0 { + b.errors = append(b.errors, v.errors...) + } + + case []error: + if len(v) > 0 { + b.errors = append(b.errors, v...) + } + + case Errors: + if len(v) > 0 { + b.errors = append(b.errors, v...) + } + + case []string: + for _, s := range v { + b.errors = append(b.errors, errors.New(s)) + } + + case error: + if v != nil { + b.errors = append(b.errors, v) + } + + case string: + b.errors = append(b.errors, errors.New(v)) + } + } + + if b.capacity > 0 && len(b.errors) > b.capacity { + b.errors = b.errors[len(b.errors)-b.capacity:] + } + + return b +} + +// First returns the first error in bundle +func (b *Bundle) First() error { + if b == nil { + return nil + } + + return b.errors.First() +} + +// Last returns the last error in bundle +func (b *Bundle) Last() error { + if b == nil { + return nil + } + + return b.errors.Last() +} + +// Get returns error by it index +func (b *Bundle) Get(index int) error { + if b == nil { + return nil + } + + return b.errors.Get(index) +} + +// All returns all errors in slice +func (b *Bundle) All() Errors { + if b == nil { + return nil + } + + return b.errors +} + +// Num returns number of errors +func (b *Bundle) Num() int { + if b == nil { + return 0 + } + + return b.errors.Num() +} + +// Cap returns maximum bundle capacity +func (b *Bundle) Cap() int { + if b == nil { + return 0 + } + + return b.capacity +} + +// IsEmpty returns true if bundle is empty +func (b *Bundle) IsEmpty() bool { + if b == nil { + return true + } + + return b.errors.IsEmpty() +} + +// Error returns text of all errors +func (b *Bundle) Error(prefix string) string { + if b == nil { + return "" + } + + return b.errors.Error(prefix) +} + +// Reset resets instance to be empty +func (b *Bundle) Reset() { + b.errors = nil +} diff --git a/errors/errors_test.go b/errors/errors_test.go new file mode 100644 index 00000000..f3d22626 --- /dev/null +++ b/errors/errors_test.go @@ -0,0 +1,200 @@ +package errors + +// ////////////////////////////////////////////////////////////////////////////////// // +// // +// Copyright (c) 2024 ESSENTIAL KAOS // +// Apache License, Version 2.0 // +// // +// ////////////////////////////////////////////////////////////////////////////////// // + +import ( + "errors" + "testing" + + . "github.com/essentialkaos/check" +) + +// ////////////////////////////////////////////////////////////////////////////////// // + +func Test(t *testing.T) { TestingT(t) } + +type ErrorsSuite struct{} + +// ////////////////////////////////////////////////////////////////////////////////// // + +var _ = Suite(&ErrorsSuite{}) + +// ////////////////////////////////////////////////////////////////////////////////// // + +func (s *ErrorsSuite) TestStd(c *C) { + c.Assert(New("test"), NotNil) + c.Assert(Is(nil, nil), Equals, true) + c.Assert(As(nil, nil), Equals, false) + c.Assert(Join(New("1"), New("2")), NotNil) + c.Assert(Unwrap(New("1")), IsNil) +} + +func (s *ErrorsSuite) TestPositive(c *C) { + var nilBundle *Bundle + var nilErrs Errors + + errs := NewBundle() + + errs.Add() + errs.Add(nil) + errs.Add(nilBundle) + errs.Add(nilErrs) + + errs.Add(errors.New("1")) + errs.Add(errors.New("2")) + errs.Add(errors.New("3")) + errs.Add(errors.New("4")) + errs.Add(errors.New("5")) + + c.Assert(errs.All(), HasLen, 5) + c.Assert(errs.Num(), Equals, 5) + c.Assert(errs.IsEmpty(), Equals, false) + c.Assert(errs.First(), DeepEquals, errors.New("1")) + c.Assert(errs.Last(), DeepEquals, errors.New("5")) + c.Assert(errs.Get(0), DeepEquals, errors.New("1")) + c.Assert(errs.Get(4), DeepEquals, errors.New("5")) + c.Assert(errs.Get(100), IsNil) + c.Assert(errs.Get(-100), IsNil) + c.Assert(errs.All(), DeepEquals, + Errors{ + errors.New("1"), + errors.New("2"), + errors.New("3"), + errors.New("4"), + errors.New("5"), + }, + ) + c.Assert(errs.Add(nil), NotNil) + c.Assert(errs.Error(" "), Equals, " 1\n 2\n 3\n 4\n 5\n") + + errs.Reset() + + c.Assert(errs.Num(), Equals, 0) +} + +func (s *ErrorsSuite) TestSizeLimit(c *C) { + errs := NewBundle(3) + + errs.Add(errors.New("1")) + errs.Add(errors.New("2")) + + c.Assert(errs.IsEmpty(), Equals, false) + c.Assert(errs.Num(), Equals, 2) + c.Assert(errs.All(), HasLen, 2) + + errs.Add(errors.New("3")) + errs.Add(errors.New("4")) + errs.Add(errors.New("5")) + errs.Add(errors.New("6")) + + c.Assert(errs.IsEmpty(), Equals, false) + c.Assert(errs.Num(), Equals, 3) + c.Assert(errs.Cap(), Equals, 3) + c.Assert(errs.All(), HasLen, 3) + + errList := errs.All() + + c.Assert(errList[0].Error(), Equals, "4") + c.Assert(errList[2].Error(), Equals, "6") + + errs = NewBundle(-10) + + c.Assert(errs.capacity, Equals, 0) +} + +func (s *ErrorsSuite) TestAdd(c *C) { + errs1 := NewBundle() + errs2 := NewBundle() + + var errs3 Bundle + + errs1.Add(errors.New("1")) + errs1.Add(errors.New("2")) + + errs2.Add(errors.New("3")) + errs2.Add(errors.New("4")) + + errs3.Add(errors.New("5")) + errs3.Add(errors.New("6")) + + errs1.Add(errs2) + errs1.Add(errs3) + + errs1.Add([]error{errors.New("7"), errors.New("8")}) + errs1.Add([]string{"9", "10"}) + errs1.Add("11") + errs1.Add(Errors{New("12")}) + + c.Assert(errs1.IsEmpty(), Equals, false) + c.Assert(errs1.Num(), Equals, 12) + c.Assert(errs1.All(), HasLen, 12) +} + +func (s *ErrorsSuite) TestNegative(c *C) { + errs := NewBundle() + + c.Assert(errs.All(), HasLen, 0) + c.Assert(errs.IsEmpty(), Equals, true) + c.Assert(errs.Last(), IsNil) + c.Assert(errs.Error(""), Equals, "") +} + +func (s *ErrorsSuite) TestNil(c *C) { + var errs *Bundle + + c.Assert(errs.Num(), Equals, 0) + c.Assert(errs.Cap(), Equals, 0) + c.Assert(errs.All(), HasLen, 0) + c.Assert(errs.IsEmpty(), Equals, true) + c.Assert(errs.First(), IsNil) + c.Assert(errs.Last(), IsNil) + c.Assert(errs.Error(""), Equals, "") + c.Assert(errs.Get(10), IsNil) +} + +func (s *ErrorsSuite) TestNoInit(c *C) { + var errs Bundle + + c.Assert(errs.Num(), Equals, 0) + c.Assert(errs.Cap(), Equals, 0) + c.Assert(errs.All(), HasLen, 0) + c.Assert(errs.IsEmpty(), Equals, true) + c.Assert(errs.First(), IsNil) + c.Assert(errs.Last(), IsNil) + c.Assert(errs.Error(""), Equals, "") + + c.Assert(errs.Add(errors.New("1")), NotNil) + c.Assert(errs.Last(), DeepEquals, errors.New("1")) +} + +func (s *ErrorsSuite) TestChain(c *C) { + f1 := func() error { + return nil + } + + f2 := func() error { + return errors.New("Error #2") + } + + f3 := func() error { + return nil + } + + c.Assert(Chain(f1, f2, f3), NotNil) + c.Assert(Chain(f1, f3), IsNil) +} + +func (s *ErrorsSuite) TestToBundle(c *C) { + errs := ToBundle([]error{ + errors.New("Error 1"), + errors.New("Error 2"), + }) + + c.Assert(errs.Num(), Equals, 2) + c.Assert(errs.Last(), DeepEquals, errors.New("Error 2")) +} diff --git a/errors/example_test.go b/errors/example_test.go new file mode 100644 index 00000000..5fb30b77 --- /dev/null +++ b/errors/example_test.go @@ -0,0 +1,307 @@ +package errors + +// ////////////////////////////////////////////////////////////////////////////////// // +// // +// Copyright (c) 2024 ESSENTIAL KAOS // +// Apache License, Version 2.0 // +// // +// ////////////////////////////////////////////////////////////////////////////////// // + +import ( + "fmt" +) + +// ////////////////////////////////////////////////////////////////////////////////// // + +func ExampleBundle() { + f1 := func() error { return nil } + f2 := func() error { return nil } + f3 := func() error { return fmt.Errorf("Error 3") } + f4 := func() error { return fmt.Errorf("Error 4") } + + // An Bundle needs no initialization + var myErrs Bundle + + myErrs.Add(f1()) + + // Using NewBundle you can create Bundle instance with limited capacity + errs := NewBundle(10) + + errs.Add(f1()) + errs.Add(f2()) + errs.Add(f3()) + errs.Add(f4()) + + fmt.Printf("Last error text: %v\n", errs.Last().Error()) + fmt.Printf("Number of errors: %d\n", errs.Num()) + fmt.Printf("Capacity: %d\n", errs.Cap()) + fmt.Printf("Has errors: %t\n", !errs.IsEmpty()) + + // Output: + // Last error text: Error 4 + // Number of errors: 2 + // Capacity: 10 + // Has errors: true +} + +func ExampleChain() { + f1 := func() error { return nil } + f2 := func() error { return nil } + f3 := func() error { return fmt.Errorf("Error 3") } + f4 := func() error { return fmt.Errorf("Error 4") } + + err := Chain(f1, f2, f3, f4) + + fmt.Println(err.Error()) + + // Output: + // Error 3 +} + +func ExampleWrap() { + e := []error{ + fmt.Errorf("Error 1"), + fmt.Errorf("Error 2"), + fmt.Errorf("Error 3"), + } + + errs := ToBundle(e) + + fmt.Printf("Last error text: %v\n", errs.Last().Error()) + fmt.Printf("Number of errors: %d\n", errs.Num()) + fmt.Printf("Has errors: %t\n", !errs.IsEmpty()) + + // Output: + // Last error text: Error 3 + // Number of errors: 3 + // Has errors: true +} + +// ////////////////////////////////////////////////////////////////////////////////// // + +func ExampleErrors_First() { + errs := Errors{ + fmt.Errorf("Error 1"), + fmt.Errorf("Error 2"), + fmt.Errorf("Error 3"), + } + + fmt.Printf("First: %v\n", errs.First()) + + // Output: + // First: Error 1 +} + +func ExampleErrors_Last() { + errs := Errors{ + fmt.Errorf("Error 1"), + fmt.Errorf("Error 2"), + fmt.Errorf("Error 3"), + } + + fmt.Printf("Last: %v\n", errs.Last()) + + // Output: + // Last: Error 3 +} + +func ExampleErrors_Get() { + errs := Errors{ + fmt.Errorf("Error 1"), + fmt.Errorf("Error 2"), + fmt.Errorf("Error 3"), + } + + fmt.Printf("Index 1: %v\n", errs.Get(1)) + fmt.Printf("Index 99: %v\n", errs.Get(99)) + + // Output: + // Index 1: Error 2 + // Index 99: +} + +func ExampleErrors_IsEmpty() { + var errs Errors + + fmt.Printf("Has errors: %t\n", !errs.IsEmpty()) + + errs = Errors{fmt.Errorf("Error 1")} + + fmt.Printf("Has errors: %t\n", !errs.IsEmpty()) + + // Output: + // Has errors: false + // Has errors: true +} + +func ExampleErrors_Num() { + errs := Errors{ + fmt.Errorf("Error 1"), + fmt.Errorf("Error 2"), + fmt.Errorf("Error 3"), + } + + fmt.Printf("Errors num: %d\n", errs.Num()) + + // Output: + // Errors num: 3 +} + +func ExampleErrors_Error() { + errs := Errors{ + fmt.Errorf("Error 1"), + fmt.Errorf("Error 2"), + fmt.Errorf("Error 3"), + } + + fmt.Printf("Errors:\n%s\n", errs.Error(" - ")) + + // Output: + // Errors: + // - Error 1 + // - Error 2 + // - Error 3 +} + +// ////////////////////////////////////////////////////////////////////////////////// // + +func ExampleBundle_Add() { + var errs Bundle + + errs.Add(fmt.Errorf("Error 1")) + errs.Add(fmt.Errorf("Error 2")) + errs.Add(fmt.Errorf("Error 3")) + + fmt.Printf("First: %v\n", errs.First()) + fmt.Printf("Last: %v\n", errs.Last()) + + // Output: + // First: Error 1 + // Last: Error 3 +} + +func ExampleBundle_First() { + var errs Bundle + + errs.Add(fmt.Errorf("Error 1")) + errs.Add(fmt.Errorf("Error 2")) + errs.Add(fmt.Errorf("Error 3")) + + fmt.Printf("First: %v\n", errs.First()) + + // Output: + // First: Error 1 +} + +func ExampleBundle_Last() { + var errs Bundle + + errs.Add(fmt.Errorf("Error 1")) + errs.Add(fmt.Errorf("Error 2")) + errs.Add(fmt.Errorf("Error 3")) + + fmt.Printf("Last: %v\n", errs.Last()) + + // Output: + // Last: Error 3 +} + +func ExampleBundle_Get() { + var errs Bundle + + errs.Add(fmt.Errorf("Error 1")) + errs.Add(fmt.Errorf("Error 2")) + errs.Add(fmt.Errorf("Error 3")) + + fmt.Printf("Index 1: %v\n", errs.Get(1)) + fmt.Printf("Index 99: %v\n", errs.Get(99)) + + // Output: + // Index 1: Error 2 + // Index 99: +} + +func ExampleBundle_All() { + var errs Bundle + + errs.Add(fmt.Errorf("Error 1")) + errs.Add(fmt.Errorf("Error 2")) + errs.Add(fmt.Errorf("Error 3")) + + fmt.Printf("Errors: %v\n", errs.All()) + + // Output: + // Errors: [Error 1 Error 2 Error 3] +} + +func ExampleBundle_IsEmpty() { + var errs Bundle + + fmt.Printf("Has errors: %t\n", !errs.IsEmpty()) + + errs.Add(fmt.Errorf("Error")) + + fmt.Printf("Has errors: %t\n", !errs.IsEmpty()) + + // Output: + // Has errors: false + // Has errors: true +} + +func ExampleBundle_Num() { + var errs Bundle + + errs.Add(fmt.Errorf("Error 1")) + errs.Add(fmt.Errorf("Error 2")) + errs.Add(fmt.Errorf("Error 3")) + + fmt.Printf("Errors num: %d\n", errs.Num()) + + // Output: + // Errors num: 3 +} + +func ExampleBundle_Cap() { + errs := NewBundle(2) + + errs.Add(fmt.Errorf("Error 1")) + errs.Add(fmt.Errorf("Error 2")) + errs.Add(fmt.Errorf("Error 3")) + + fmt.Printf("Errors cap: %d\n", errs.Cap()) + fmt.Printf("First: %v\n", errs.First()) + fmt.Printf("Last: %v\n", errs.Last()) + + // Output: + // Errors cap: 2 + // First: Error 2 + // Last: Error 3 +} + +func ExampleBundle_Error() { + var errs Bundle + + errs.Add(fmt.Errorf("Error 1")) + errs.Add(fmt.Errorf("Error 2")) + errs.Add(fmt.Errorf("Error 3")) + + fmt.Printf("Errors:\n%s\n", errs.Error(" - ")) + + // Output: + // Errors: + // - Error 1 + // - Error 2 + // - Error 3 +} + +func ExampleBundle_Reset() { + var errs Bundle + + errs.Add(fmt.Errorf("Error")) + errs.Reset() + + fmt.Printf("Has errors: %t\n", !errs.IsEmpty()) + + // Output: + // Has errors: false +} diff --git a/errutil/errutil.go b/errutil/errutil.go index 21e2f846..324de752 100644 --- a/errutil/errutil.go +++ b/errutil/errutil.go @@ -1,4 +1,6 @@ // Package errutil provides methods for working with errors +// +// Deprecated: Use package errors instead package errutil // ////////////////////////////////////////////////////////////////////////////////// // @@ -23,6 +25,8 @@ type Errors struct { // ////////////////////////////////////////////////////////////////////////////////// // // NewErrors creates new struct +// +// Deprecated: Use package errors instead func NewErrors(capacity ...int) *Errors { if len(capacity) == 0 { return &Errors{} @@ -38,12 +42,16 @@ func NewErrors(capacity ...int) *Errors { } // Wrap wraps slice of errors into Errors struct +// +// Deprecated: Use package errors instead func Wrap(errs []error) *Errors { return &Errors{errors: errs} } // Chain executes functions in chain and if one of them return error // this function stop chain execution and return this error +// +// Deprecated: Use package errors instead func Chain(funcs ...func() error) error { var err error @@ -61,6 +69,8 @@ func Chain(funcs ...func() error) error { // ////////////////////////////////////////////////////////////////////////////////// // // Add adds new error to slice +// +// Deprecated: Use package errors instead func (e *Errors) Add(errs ...any) *Errors { if errs == nil { return e @@ -95,6 +105,8 @@ func (e *Errors) Add(errs ...any) *Errors { } // First returns the first error +// +// Deprecated: Use package errors instead func (e *Errors) First() error { if e == nil || len(e.errors) == 0 { return nil @@ -104,6 +116,8 @@ func (e *Errors) First() error { } // Last returns the last error +// +// Deprecated: Use package errors instead func (e *Errors) Last() error { if e == nil || len(e.errors) == 0 { return nil @@ -113,6 +127,8 @@ func (e *Errors) Last() error { } // Get returns error by it index +// +// Deprecated: Use package errors instead func (e *Errors) Get(index int) error { if e == nil || len(e.errors) == 0 || index < 0 || index >= len(e.errors) { @@ -123,6 +139,8 @@ func (e *Errors) Get(index int) error { } // All returns all errors in slice +// +// Deprecated: Use package errors instead func (e *Errors) All() []error { if e == nil || e.errors == nil { return nil @@ -132,6 +150,8 @@ func (e *Errors) All() []error { } // HasErrors checks if slice contains errors +// +// Deprecated: Use package errors instead func (e *Errors) HasErrors() bool { if e == nil || e.errors == nil { return false @@ -141,6 +161,8 @@ func (e *Errors) HasErrors() bool { } // Num returns number of errors +// +// Deprecated: Use package errors instead func (e *Errors) Num() int { if e == nil { return 0 @@ -150,6 +172,8 @@ func (e *Errors) Num() int { } // Cap returns max capacity +// +// Deprecated: Use package errors instead func (e *Errors) Cap() int { if e == nil { return 0 @@ -159,6 +183,8 @@ func (e *Errors) Cap() int { } // Error returns text of all errors +// +// Deprecated: Use package errors instead func (e *Errors) Error() string { if e == nil || len(e.errors) == 0 { return "" @@ -174,6 +200,8 @@ func (e *Errors) Error() string { } // Reset resets Errors instance to be empty +// +// Deprecated: Use package errors instead func (e *Errors) Reset() { e.errors = nil } diff --git a/version.go b/version.go index b54d46e2..fe8c3db3 100644 --- a/version.go +++ b/version.go @@ -8,4 +8,4 @@ package ek // ////////////////////////////////////////////////////////////////////////////////// // // VERSION is current ek package version -const VERSION = "13.8.2" +const VERSION = "13.9.0"