mirror of
https://github.com/grafana/grafana.git
synced 2024-11-27 19:30:36 -06:00
16c185c3b9
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
25 lines
511 B
Go
25 lines
511 B
Go
package errutil
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
// Wrap is a simple wrapper around fmt.Errorf that wraps errors.
|
|
func Wrap(message string, err error) error {
|
|
if err == nil {
|
|
return nil
|
|
}
|
|
|
|
return fmt.Errorf("%v: %w", message, err)
|
|
}
|
|
|
|
// Wrapf is a simple wrapper around fmt.Errorf that wraps errors.
|
|
// Wrapf allows you to send a format and args instead of just a message.
|
|
func Wrapf(err error, message string, a ...interface{}) error {
|
|
if err == nil {
|
|
return nil
|
|
}
|
|
|
|
return Wrap(fmt.Sprintf(message, a...), err)
|
|
}
|