2021-05-02 06:36:10 +00:00
|
|
|
package errorutil
|
2021-02-27 10:33:16 +00:00
|
|
|
|
|
|
|
import (
|
2021-05-02 11:16:32 +00:00
|
|
|
"github.com/Kichiyaki/appmode"
|
2021-02-27 10:33:16 +00:00
|
|
|
"github.com/pkg/errors"
|
|
|
|
)
|
|
|
|
|
|
|
|
func Wrap(details error, message string) error {
|
2021-05-02 11:16:32 +00:00
|
|
|
if appmode.Equals(appmode.ProductionMode) {
|
2021-04-19 20:23:10 +00:00
|
|
|
return errors.New(message)
|
|
|
|
}
|
2021-03-27 15:20:55 +00:00
|
|
|
return errors.Wrap(details, message)
|
2021-02-27 10:33:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func Wrapf(details error, message string, args ...interface{}) error {
|
2021-05-02 11:16:32 +00:00
|
|
|
if appmode.Equals(appmode.ProductionMode) {
|
2021-04-19 20:23:10 +00:00
|
|
|
return errors.Errorf(message, args...)
|
2021-02-27 10:33:16 +00:00
|
|
|
}
|
2021-04-19 20:23:10 +00:00
|
|
|
return errors.Wrapf(details, message, args...)
|
2021-02-27 10:33:16 +00:00
|
|
|
}
|