mirror of
https://github.com/mickael-menu/zk
synced 2024-11-13 01:10:43 +00:00
27 lines
493 B
Go
27 lines
493 B
Go
package errors
|
|
|
|
import (
|
|
"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)
|
|
}
|