github.com/Synthesix/Sia@v1.3.3-0.20180413141344-f863baeed3ca/build/critical.go (about)

     1  package build
     2  
     3  import (
     4  	"fmt"
     5  	"os"
     6  	"runtime/debug"
     7  )
     8  
     9  // Critical should be called if a sanity check has failed, indicating developer
    10  // error. Critical is called with an extended message guiding the user to the
    11  // issue tracker on Github. If the program does not panic, the call stack for
    12  // the running goroutine is printed to help determine the error.
    13  func Critical(v ...interface{}) {
    14  	s := "Critical error: " + fmt.Sprintln(v...) + "Please submit a bug report here: https://github.com/Synthesix/Sia/issues\n"
    15  	if Release != "testing" {
    16  		debug.PrintStack()
    17  		os.Stderr.WriteString(s)
    18  	}
    19  	if DEBUG {
    20  		panic(s)
    21  	}
    22  }
    23  
    24  // Severe will print a message to os.Stderr. If DEBUG has been set panic will
    25  // be called as well. Severe should be called in situations which indicate
    26  // significant problems for the user (such as disk failure or random number
    27  // generation failure), but where crashing is not strictly required to preserve
    28  // integrity.
    29  func Severe(v ...interface{}) {
    30  	s := "Severe error: " + fmt.Sprintln(v...)
    31  	if Release != "testing" {
    32  		debug.PrintStack()
    33  		os.Stderr.WriteString(s)
    34  	}
    35  	if DEBUG {
    36  		panic(s)
    37  	}
    38  }