From 9e4971bef47bb088c981f1bfa4ca6de909060722 Mon Sep 17 00:00:00 2001 From: Philip O'Toole Date: Sat, 28 Jan 2023 18:34:56 -0500 Subject: [PATCH] Better error message for "connection refused" --- cmd/rqlite/main.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/rqlite/main.go b/cmd/rqlite/main.go index 44b0256b..b8f4318a 100644 --- a/cmd/rqlite/main.go +++ b/cmd/rqlite/main.go @@ -14,6 +14,7 @@ import ( "os" "sort" "strings" + "syscall" "time" "github.com/Bowery/prompt" @@ -80,7 +81,12 @@ func main() { version, err := getVersionWithClient(httpClient, argv) if err != nil { - ctx.String("%s %v\n", ctx.Color().Red("ERR!"), err) + msg := err.Error() + if errors.Is(err, syscall.ECONNREFUSED) { + msg = fmt.Sprintf("Unable to connect to rqlited at %s://%s:%d - is it running?", + argv.Protocol, argv.Host, argv.Port) + } + ctx.String("%s %v\n", ctx.Color().Red("ERR!"), msg) return nil }