replace Fatalf function with fmt.Errorf

This commit is contained in:
Manav Darji 2022-01-25 16:41:05 +05:30
parent 08f9931147
commit 6ccd75c186
2 changed files with 2 additions and 23 deletions

View file

@ -687,11 +687,11 @@ func (c *Config) buildEth(stack *node.Node) (*ethconfig.Config, error) {
} else { } else {
developer, err = ks.NewAccount(passphrase) developer, err = ks.NewAccount(passphrase)
if err != nil { if err != nil {
Fatalf("Failed to create developer account: %v", err) return nil, fmt.Errorf("failed to create developer account: %v", err)
} }
} }
if err := ks.Unlock(developer, passphrase); err != nil { if err := ks.Unlock(developer, passphrase); err != nil {
Fatalf("Failed to unlock developer account: %v", err) return nil, fmt.Errorf("failed to unlock developer account: %v", err)
} }
log.Info("Using developer account", "address", developer.Address) log.Info("Using developer account", "address", developer.Address)

View file

@ -7,7 +7,6 @@ import (
"net" "net"
"net/http" "net/http"
"os" "os"
"runtime"
"strings" "strings"
"time" "time"
@ -285,23 +284,3 @@ func setupLogger(logLevel string) {
} }
log.Root().SetHandler(glogger) log.Root().SetHandler(glogger)
} }
// Fatalf formats a message to standard error and exits the program.
// The message is also printed to standard output if standard error
// is redirected to a different file.
func Fatalf(format string, args ...interface{}) {
w := io.MultiWriter(os.Stdout, os.Stderr)
if runtime.GOOS == "windows" {
// The SameFile check below doesn't work on Windows.
// stdout is unlikely to get redirected though, so just print there.
w = os.Stdout
} else {
outf, _ := os.Stdout.Stat()
errf, _ := os.Stderr.Stat()
if outf != nil && errf != nil && os.SameFile(outf, errf) {
w = os.Stderr
}
}
fmt.Fprintf(w, "Fatal: "+format+"\n", args...)
os.Exit(1)
}