From ba2b3177d8baa07c5fe16f4b7af05975227d1754 Mon Sep 17 00:00:00 2001 From: Josh Robson Chase Date: Thu, 28 Dec 2023 11:25:07 -0500 Subject: [PATCH] errors: include a link in the Error() message --- errors.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/errors.go b/errors.go index 44485381..066fdab9 100644 --- a/errors.go +++ b/errors.go @@ -3,6 +3,7 @@ package ngrok import ( "fmt" "net/url" + "strings" ) // Error is an error enriched with a specific ErrorCode. @@ -139,8 +140,14 @@ type ngrokError struct { ErrCode string } +const errUrl = "https://ngrok.com/docs/errors" + func (m ngrokError) Error() string { - return m.Message + "\n\n" + m.ErrCode + out := m.Message + if m.ErrCode != "" { + out = fmt.Sprintf("%s\n\n%s/%s", out, errUrl, strings.ToLower(m.ErrCode)) + } + return out } func (m ngrokError) Msg() string {