Skip to content

Commit 8321155

Browse files
committed
fix: error handling
1 parent 497383c commit 8321155

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

cmd/main.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import (
66
"path/filepath"
77
"strconv"
88

9+
"github.com/flanksource/clicky"
910
"github.com/samber/lo"
1011
"github.com/spf13/cobra"
1112

12-
"github.com/flanksource/clicky"
1313
"github.com/flanksource/postgres/pkg"
1414
"github.com/flanksource/postgres/pkg/config"
1515
"github.com/flanksource/postgres/pkg/pgtune"
@@ -53,7 +53,8 @@ func getPostgresPassword() utils.SensitiveString {
5353
}
5454

5555
func main() {
56-
clicky.Infof(GetVersionInfo())
56+
clicky.Infof("%s", GetVersionInfo())
57+
5758
rootCmd := &cobra.Command{
5859
Use: "postgres-cli",
5960
Short: "PostgreSQL Management CLI",
@@ -66,11 +67,12 @@ This unified tool combines PostgreSQL server management, configuration generatio
6667

6768
// Load configuration if specified
6869
if configFile != "" {
69-
if pconfig, err := config.LoadPostgresConf(configFile); err == nil {
70-
return err
71-
} else {
72-
postgres.Config = pconfig
70+
pconfig, err := config.LoadPostgresConf(configFile)
71+
if err != nil {
72+
return fmt.Errorf("failed to load postgres config file(%s): %w", configFile, err)
7373
}
74+
75+
postgres.Config = pconfig
7476
} else if postgres.Config == nil {
7577
postgres.Config = config.DefaultPostgresConf()
7678
}

0 commit comments

Comments
 (0)