mirror of
https://github.com/mickael-menu/zk
synced 2024-11-07 15:20:21 +00:00
32 lines
561 B
Go
32 lines
561 B
Go
package errors
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
)
|
|
|
|
func Wrapperf(format string, args ...interface{}) func(error) error {
|
|
return Wrapper(fmt.Sprintf(format, args...))
|
|
}
|
|
|
|
func Wrapper(msg string) func(error) error {
|
|
return func(err error) error {
|
|
return Wrap(err, msg)
|
|
}
|
|
}
|
|
|
|
func Wrapf(err error, format string, args ...interface{}) error {
|
|
return Wrap(err, fmt.Sprintf(format, args...))
|
|
}
|
|
|
|
func Wrap(err error, msg string) error {
|
|
if err == nil {
|
|
return nil
|
|
}
|
|
return fmt.Errorf("%s: %w", msg, err)
|
|
}
|
|
|
|
func New(text string) error {
|
|
return errors.New(text)
|
|
}
|