replace tozd/errors with Southclaws/fault
1 file changed, 9 insertions(+), 7 deletions(-)
changed files
M internal/config/config.go → internal/config/config.go
@@ -1,6 +1,7 @@ package config import ( + "fmt" "io/fs" "net/url" "path/filepath"@@ -9,7 +10,8 @@ "go.alanpearce.eu/x/log" "github.com/BurntSushi/toml" - "gitlab.com/tozd/go/errors" + "github.com/Southclaws/fault" + "github.com/Southclaws/fault/fmsg" ) type Taxonomy struct {@@ -38,7 +40,7 @@ func (u *URL) UnmarshalText(text []byte) (err error) { u.URL, err = url.Parse(string(text)) - return errors.WithMessagef(err, "could not parse URL %s", string(text)) + return fault.Wrap(err, fmsg.With(fmt.Sprintf("could not parse URL %s", string(text)))) } type Timezone struct {@@ -48,7 +50,7 @@ func (t *Timezone) UnmarshalText(text []byte) (err error) { t.Location, err = time.LoadLocation(string(text)) - return errors.WithMessagef(err, "could not parse timezone %s", string(text)) + return fault.Wrap(err, fmsg.With(fmt.Sprintf("could not parse timezone %s", string(text)))) } type Config struct {@@ -73,7 +75,7 @@ Menu []MenuItem RelMe []MenuItem `toml:"rel_me"` } -func GetConfig(dir string, log *log.Logger) (*Config, errors.E) { +func GetConfig(dir string, log *log.Logger) (*Config, error) { config := &Config{} filename := filepath.Join(dir, "config.toml") log.Debug("reading config", "filename", filename)@@ -81,12 +83,12 @@ _, err := toml.DecodeFile(filename, config) if err != nil { switch t := err.(type) { case *fs.PathError: - return nil, errors.WithMessage(t, "could not read configuration") + return nil, fault.Wrap(t, fmsg.With("could not read configuration")) case *toml.ParseError: - return nil, errors.WithMessage(t, t.ErrorWithUsage()) + return nil, fault.Wrap(t, fmsg.With(t.ErrorWithUsage())) } - return nil, errors.WithMessage(err, "config error") + return nil, fault.Wrap(err, fmsg.With("config error")) } return config, nil