From 86497d8b5c2ea6459d318c1a5843ec5fd3bef67c Mon Sep 17 00:00:00 2001 From: Sebastian Gumprich Date: Wed, 1 Nov 2023 10:02:22 +0100 Subject: [PATCH] add better error messages and debugging output --- conf/main.go | 2 ++ main.go | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/conf/main.go b/conf/main.go index ace9948..8b7d42a 100644 --- a/conf/main.go +++ b/conf/main.go @@ -21,7 +21,9 @@ func ReadConf() { func ParseCliOpts() { var versionFlag bool + var debugFlag bool pflag.BoolVar(&versionFlag, "version", false, "Print the version of the program") + pflag.BoolVar(&debugFlag, "debug", false, "enable debug outpuz") pflag.StringP("confluence_url", "u", "https://confluence.example.com/rest/api", "The URL to the Confluence REST-API with http(s)") pflag.StringP("confluence_token", "t", "", "The token to authenticate against the Confluence REST-API") diff --git a/main.go b/main.go index 465157b..d99a506 100644 --- a/main.go +++ b/main.go @@ -34,14 +34,16 @@ func main() { domain := getDomainName(cURL) + goconfluence.SetDebug(viper.GetViper().GetBool("debug")) + api, err := goconfluence.NewAPI(cURL, "", cToken) if err != nil { - log.Fatal(err) + log.Fatal("Error connecting to Confluence: ", err) } childPages, err := api.GetChildPages(cPageID) if err != nil { - log.Fatal(err) + log.Fatal("Error getting child pages: ", err) } now := time.Now() @@ -57,7 +59,7 @@ func main() { for _, v := range childPages.Results { hist, err := api.GetHistory(v.ID) if err != nil { - log.Fatal(err) + log.Fatal("Error getting history: ", err) } lastUpdateTimeString := hist.LastUpdated.When lastUpdateTime, err := time.Parse("2006-01-02T15:04:05.000Z", lastUpdateTimeString)