Replaced 'panic' with an error return, and a call to 'printAndExit'

This commit is contained in:
2024-08-10 11:27:57 -05:00
parent 71051ce7f0
commit 2a007ba56c
4 changed files with 24 additions and 17 deletions

View File

@@ -49,10 +49,11 @@ func newColor(colorString string) (color, error) {
return clr, nil
}
// newColorMust is similar to newColor, but panics if the given color isn't valid.
// newColorMust is similar to newColor, but prints an error and exits if the given color isn't valid.
func newColorMust(colorString string) color {
if clr, err := newColor(colorString); err != nil {
panic(err)
printAndExit(err.Error())
panic(err) // NEVER REACHED
} else {
return clr
}