From 0472e8edecf24abbbc8be7831135ea7b6b7f58d4 Mon Sep 17 00:00:00 2001 From: Chris Cummer Date: Thu, 12 Apr 2018 08:56:33 -0700 Subject: [PATCH] Remove some panics, replace with error percolation --- bamboohr/request.go | 2 +- newrelic/widget.go | 2 +- wtf.go | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/bamboohr/request.go b/bamboohr/request.go index b46faac0..04de945a 100644 --- a/bamboohr/request.go +++ b/bamboohr/request.go @@ -8,7 +8,7 @@ import ( func Request(apiKey string, apiURL string) ([]byte, error) { req, err := http.NewRequest("GET", apiURL, nil) if err != nil { - panic(err) + return nil, err } req.SetBasicAuth(apiKey, "x") diff --git a/newrelic/widget.go b/newrelic/widget.go index a3f846c9..dc86227e 100644 --- a/newrelic/widget.go +++ b/newrelic/widget.go @@ -86,7 +86,7 @@ func (widget *Widget) contentFrom(deploys []nr.ApplicationDeployment) string { } str = str + fmt.Sprintf( - " [green]%s[%s] %s %-16s[white]\n", + " [green]%s[%s] %s %-.16s[white]\n", deploy.Revision[0:8], lineColor, deploy.Timestamp.Format("Jan 02, 15:04 MST"), diff --git a/wtf.go b/wtf.go index c0fb762d..aa5f76ef 100644 --- a/wtf.go +++ b/wtf.go @@ -1,6 +1,7 @@ package main import ( + "os" "time" "github.com/rivo/tview" @@ -121,6 +122,6 @@ func main() { go refresher(stat, app) if err := app.SetRoot(grid, true).Run(); err != nil { - panic(err) + os.Exit(1) } }