mirror of
https://github.com/go-i2p/go-i2p.git
synced 2025-06-09 02:43:30 -04:00
32 lines
964 B
Go
32 lines
964 B
Go
package data
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/samber/oops"
|
|
)
|
|
|
|
var (
|
|
ErrZeroLength = oops.Errorf("error parsing string: zero length")
|
|
ErrDataTooShort = oops.Errorf("string parsing warning: string data is shorter than specified by length")
|
|
ErrDataTooLong = oops.Errorf("string parsing warning: string contains data beyond length")
|
|
ErrLengthMismatch = oops.Errorf("error reading I2P string, length does not match data")
|
|
ErrMappingLengthMismatch = oops.Errorf("warning parsing mapping: mapping length exceeds provided data")
|
|
)
|
|
|
|
// WrapErrors compiles a slice of errors and returns them wrapped together as a single error.
|
|
func WrapErrors(errs []error) error {
|
|
var err error
|
|
for i, e := range errs {
|
|
err = oops.Errorf("%v\n\t%d: %v", err, i, e)
|
|
}
|
|
return err
|
|
}
|
|
|
|
// PrintErrors prints a formatted list of errors to the console.
|
|
func PrintErrors(errs []error) {
|
|
for i, e := range errs {
|
|
fmt.Printf("\t%d: %v\n", i, e)
|
|
}
|
|
}
|