argo-cd/errors/errors.go

21 lines
439 B
Go
Raw Normal View History

2018-02-15 00:53:07 +00:00
package errors
import (
log "github.com/sirupsen/logrus"
)
// CheckError is a convenience function to exit if an error is non-nil and exit if it was
2018-02-15 00:53:07 +00:00
func CheckError(err error) {
if err != nil {
log.Fatal(err)
}
}
2019-05-15 16:24:35 +00:00
// panics if there is an error.
// This returns the first value so you can use it if you cast it:
// text := FailOrErr(Foo)).(string)
func FailOnErr(v interface{}, err error) interface{} {
2019-05-15 16:24:35 +00:00
CheckError(err)
return v
2019-05-15 16:24:35 +00:00
}