Simple Multiple error management in go
. Some features include :
- Merge Multiple error
- Similar Methods
Append
&Len
- Multiple Displays
string
,line
orTab
- No External dependency
Run go get github.com/olekukonko/merror
to download and install
package main
import (
"fmt"
"errors"
"github.com/olekukonko/merror"
)
func main() {
// new Multiple Error
err := merror.Multi()
// Append Simple error
err.Append(errors.New("Error A"))
// Append Multiple
err.Append(errors.New("Error B"),errors.New("Error C"))
// Print Error
fmt.Println(err)
// Output:
// Error A ; Error B; Error C
}
package main
import (
"fmt"
"errors"
"github.com/olekukonko/merror"
"os"
)
func main() {
// new Multiple Error
err := merror.Multi()
// Append Simple error
err.Append(errors.New("Error A"))
// Append Multiple
err.Append(errors.New("Error B"),errors.New("Error C"))
// Send to output command line or http
err.Tab(os.Stdout)
// Output:
// 3 Error(s) Found
// - Error A
// - Error B
// - Error C
}