pulumi/pkg/util/fail.go
joeduffy 11f7f4963f Go back to glog.Fail
Well, it turns out glog.Fail is slightly better than panic, because it explicitly
dumps the stacks of *all* goroutines.  This is especially good in logging scenarios.
It's really annoying that glog suppresses printing the stack trace (see here
https://github.com/golang/glog/blob/master/glog.go#L719), however this is better.
2016-12-01 11:50:19 -08:00

32 lines
725 B
Go

// Copyright 2016 Marapongo, Inc. All rights reserved.
package util
import (
"fmt"
"github.com/golang/glog"
)
const failMsg = "A failure has occurred"
// Fail unconditionally abandons the process.
func Fail() {
failfast(failMsg)
}
// FailM unconditionally abandons the process, logging the given message.
func FailM(msg string) {
failfast(fmt.Sprintf("%v: %v", failMsg, msg))
}
// FailMF unconditionally abandons the process, formatting and logging the given message.
func FailMF(msg string, args ...interface{}) {
failfast(fmt.Sprintf("%v: %v", failMsg, fmt.Sprintf(msg, args...)))
}
// failfast logs and panics the process in a way that is friendly to debugging.
func failfast(msg string) {
glog.Fatal(msg)
}