Documentation ¶
Overview ¶
Example ¶
// some input data f := math.NaN() i := -32 var s string // checking var et Tree et.Name = "Check input data" if math.IsNaN(f) { et.Add(ErrorValue{ ValueName: "f", Reason: fmt.Errorf("is NaN"), }) } if f < 0 { et.Add(fmt.Errorf("Parameter `f` is negative")) } if i < 0 { et.Add(fmt.Errorf("Parameter `i` is less zero")) } if s == "" { et.Add(fmt.Errorf("Parameter `s` is empty")) } if et.IsError() { fmt.Println(et.Error()) } // walk Walk(&et, func(e error) { fmt.Fprintf(os.Stdout, "%-25s %v\n", fmt.Sprintf("%T", e), e) })
Output: Check input data ├──Value `f`: is NaN ├──Parameter `i` is less zero └──Parameter `s` is empty errors.ErrorValue Value `f`: is NaN *errors.errorString Parameter `i` is less zero *errors.errorString Parameter `s` is empty
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Tree ¶
type Tree struct { Name string // contains filtered or unexported fields }
Tree is struct of error tree
Example ¶
et := New("Check error tree") for i := 0; i < 2; i++ { et.Add(fmt.Errorf("Error case %d", i)) } fmt.Println(et.Error()) // walk Walk(et, func(e error) { fmt.Fprintf(os.Stdout, "%T %v\n", e, e) })
Output: Check error tree ├──Error case 0 └──Error case 1 *errors.errorString Error case 0 *errors.errorString Error case 1
Click to show internal directories.
Click to hide internal directories.