mirror of
https://github.com/grafana/grafana.git
synced 2024-12-02 05:29:42 -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)
|
|
}
|