diff options
author | Robin Jarry <robin@jarry.cc> | 2024-02-12 11:04:29 +0100 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2024-02-14 23:05:15 +0100 |
commit | abfb20f1d62c511778f8ee811a3ff6a02e93a32f (patch) | |
tree | f7ddf1ec2801e7bc0be59b5994b8cc3d8e6009ed /config | |
parent | 2e5d9536412ddbb8d1a2bc71efe84040857b30a3 (diff) | |
download | aerc-abfb20f1d62c511778f8ee811a3ff6a02e93a32f.tar.gz |
config: improve styleset error reporting
Include the styleset filepath and exact statement that caused the error.
Remove the "failed to load config: " prefix in the error message. The
line is often very long already.
Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Diffstat (limited to 'config')
-rw-r--r-- | config/style.go | 6 | ||||
-rw-r--r-- | config/ui.go | 6 |
2 files changed, 7 insertions, 5 deletions
diff --git a/config/style.go b/config/style.go index 1b428f45..95e60616 100644 --- a/config/style.go +++ b/config/style.go @@ -468,7 +468,7 @@ func (ss *StyleSet) ParseStyleSet(file *ini.File) error { ss.user[styleName] = s } if err := s.Set(attr, val); err != nil { - return err + return fmt.Errorf("[user].%s=%s: %w", key, val, err) } } @@ -500,12 +500,12 @@ func (ss *StyleSet) parseKey(key *ini.Key, selected bool) error { if !selected { err = ss.objects[so].update(header, pattern, attr, key.Value()) if err != nil { - return err + return fmt.Errorf("%s=%s: %w", key.Name(), key.Value(), err) } } err = ss.selected[so].update(header, pattern, attr, key.Value()) if err != nil { - return err + return fmt.Errorf("%s=%s: %w", key.Name(), key.Value(), err) } num++ } diff --git a/config/ui.go b/config/ui.go index e7e96f9f..8b10c8a8 100644 --- a/config/ui.go +++ b/config/ui.go @@ -246,8 +246,10 @@ func (ui *UIConfig) loadStyleSet(styleSetDirs []string) error { ui.style = NewStyleSet() err := ui.style.LoadStyleSet(ui.StyleSetName, styleSetDirs) if err != nil { - return fmt.Errorf("Unable to load %q styleset: %w", - ui.StyleSetName, err) + if ui.style.path == "" { + ui.style.path = ui.StyleSetName + } + return fmt.Errorf("%s: %w", ui.style.path, err) } return nil |