From e6df23b3f95433141ecacd0219230e7fa1034ef9 Mon Sep 17 00:00:00 2001 From: Hubert Hirtz Date: Fri, 30 Apr 2021 10:17:16 +0200 Subject: Better error reporting about configuration file - Better errors in config.go - Do not print useless timestamps in cmd/senpai/main.go - Let os.UserConfigDir() and senpai.NewApp() call panic on error since they both should not fail. --- cmd/senpai/main.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'cmd/senpai') diff --git a/cmd/senpai/main.go b/cmd/senpai/main.go index d428ccf..c2992b0 100644 --- a/cmd/senpai/main.go +++ b/cmd/senpai/main.go @@ -2,7 +2,7 @@ package main import ( "flag" - "log" + "fmt" "math/rand" "os" "path" @@ -28,21 +28,22 @@ func main() { if configPath == "" { configDir, err := os.UserConfigDir() if err != nil { - log.Panicln(err) + panic(err) } configPath = path.Join(configDir, "senpai", "senpai.yaml") } cfg, err := senpai.LoadConfigFile(configPath) if err != nil { - log.Panicln(err) + fmt.Printf("failed to load the required configuraiton file at %q: %s\n", configPath, err) + os.Exit(1) } cfg.Debug = cfg.Debug || debug app, err := senpai.NewApp(cfg) if err != nil { - log.Panicln(err) + panic(err) } defer app.Close() -- cgit v1.2.3