Fix runtime panics being suppressed

fatalLog was matching runtime errors, and essentially hiding them.

Test: m blueprint_tools
Change-Id: Ib48e7e142fc096998bc14b21fb717392adcff0ec
This commit is contained in:
Dan Willemsen
2019-01-28 20:00:01 -08:00
parent 62f6fcbbb9
commit ef661b7f18
2 changed files with 20 additions and 4 deletions

View File

@@ -73,7 +73,9 @@ type Logger interface {
}
// fatalLog is the type used when Fatal[f|ln]
type fatalLog error
type fatalLog struct {
error
}
func fileRotation(from, baseName, ext string, cur, max int) error {
newName := baseName + "." + strconv.Itoa(cur) + ext
@@ -273,7 +275,7 @@ func (s *stdLogger) Verboseln(v ...interface{}) {
func (s *stdLogger) Fatal(v ...interface{}) {
output := fmt.Sprint(v...)
s.Output(2, output)
panic(fatalLog(errors.New(output)))
panic(fatalLog{errors.New(output)})
}
// Fatalf is equivalent to Printf() followed by a call to panic() that
@@ -281,7 +283,7 @@ func (s *stdLogger) Fatal(v ...interface{}) {
func (s *stdLogger) Fatalf(format string, v ...interface{}) {
output := fmt.Sprintf(format, v...)
s.Output(2, output)
panic(fatalLog(errors.New(output)))
panic(fatalLog{errors.New(output)})
}
// Fatalln is equivalent to Println() followed by a call to panic() that
@@ -289,7 +291,7 @@ func (s *stdLogger) Fatalf(format string, v ...interface{}) {
func (s *stdLogger) Fatalln(v ...interface{}) {
output := fmt.Sprintln(v...)
s.Output(2, output)
panic(fatalLog(errors.New(output)))
panic(fatalLog{errors.New(output)})
}
// Panic is equivalent to Print() followed by a call to panic().