From eff9c0c8c6d32c2060841a9b9b98d9d4b38540b2 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Wed, 17 Nov 2021 10:30:17 +0100 Subject: Refactored to replace github pkg errors dependencies with fmt.Errorf --- pkg/config/config.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'pkg/config/config.go') diff --git a/pkg/config/config.go b/pkg/config/config.go index b68a26a..b363a0c 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -1,9 +1,9 @@ package config import ( + "fmt" "os" - "github.com/pkg/errors" "gopkg.in/yaml.v3" ) @@ -23,7 +23,7 @@ func (c *Config) validate() error { } // Menus if len(c.Menus) < 2 { - return errors.New("A valid configuration needs at least two menu entries named anonymous and logged_in") + return fmt.Errorf("A valid configuration needs at least two menu entries named anonymous and logged_in") } for k, v := range c.Menus { if err := v.validate(k); err != nil { @@ -44,20 +44,20 @@ func LoadFile(path string) (*Config, error) { var c *Config f, errOpen := os.Open(path) if errOpen != nil { - return nil, errors.Wrapf(errOpen, "Failed to open configuration file %s", path) + return nil, fmt.Errorf("Failed to open configuration file %s : %w", path, errOpen) } defer f.Close() decoder := yaml.NewDecoder(f) if err := decoder.Decode(&c); err != nil { - return nil, errors.Wrap(err, "Failed to decode configuration file") + return nil, fmt.Errorf("Failed to decode configuration file : %w", err) } if err := c.validate(); err != nil { - return nil, errors.Wrap(err, "Failed to validate configuration") + return nil, fmt.Errorf("Failed to validate configuration : %w", err) } // If all looks good we validate menu consistency for _, v := range c.Menus { if err := v.validateConsistency(c); err != nil { - return nil, errors.Wrap(err, "Failed menu consistency checks") + return nil, fmt.Errorf("Failed menu consistency checks : %w", err) } } return c, nil -- cgit v1.2.3