mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-24 01:30:25 +08:00
ae87114282
* chore: change interface{} to any * chore: update goctl version to 1.5.0 * chore: update goctl deps
22 lines
442 B
Go
22 lines
442 B
Go
package errorx
|
|
|
|
import "fmt"
|
|
|
|
// Wrap returns an error that wraps err with given message.
|
|
func Wrap(err error, message string) error {
|
|
if err == nil {
|
|
return nil
|
|
}
|
|
|
|
return fmt.Errorf("%s: %w", message, err)
|
|
}
|
|
|
|
// Wrapf returns an error that wraps err with given format and args.
|
|
func Wrapf(err error, format string, args ...any) error {
|
|
if err == nil {
|
|
return nil
|
|
}
|
|
|
|
return fmt.Errorf("%s: %w", fmt.Sprintf(format, args...), err)
|
|
}
|