pulumi/pkg/util/fail.go
joeduffy c20c151edf Use assertions in more places
This change mostly replaces explicit if/then/glog.Fatalf calls with
util.Assert calls.  In addition, it adds a companion util.Fail family
of methods that does the same thing as a failed assertion, except that
it is unconditional.
2016-11-19 16:13:13 -08:00

27 lines
582 B
Go

// Copyright 2016 Marapongo, Inc. All rights reserved.
package util
import (
"fmt"
"github.com/golang/glog"
)
const failMsg = "A fail error has occurred"
// Fail unconditionally abandons the process.
func Fail() {
glog.Fatal(failMsg)
}
// FailM unconditionally abandons the process, logging the given message.
func FailM(msg string) {
glog.Fatalf("%v: %v", failMsg, msg)
}
// FailMF unconditionally abandons the process, formatting and logging the given message.
func FailMF(msg string, args ...interface{}) {
glog.Fatalf("%v: %v", failMsg, fmt.Sprintf(msg, args...))
}