From f455056d25a275e49a80b6e3ce3c5cfd9ab20f23 Mon Sep 17 00:00:00 2001 From: Eugene Kim Date: Sat, 14 Dec 2019 09:48:58 -0800 Subject: [PATCH] Add utils.Fatal, a print-to-stderr-and-exit helper --- internal/utils/utils.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/utils/utils.go b/internal/utils/utils.go index 03ace332c..f0eae83a9 100644 --- a/internal/utils/utils.go +++ b/internal/utils/utils.go @@ -273,6 +273,12 @@ func AppendIfMissing(slice []common.Address, addr common.Address) []common.Addre return append(slice, addr) } +// Fatal prints the given message onto stderr, then exits with status 1. +func Fatal(format string, args ...interface{}) { + _, _ = fmt.Fprintf(os.Stderr, format, args...) + os.Exit(1) +} + // PrintError prints the given error in the extended format (%+v) onto stderr. func PrintError(err error) { _, _ = fmt.Fprintf(os.Stderr, "%+v\n", err)