aboutsummaryrefslogtreecommitdiffstats
path: root/config/accounts.go
diff options
context:
space:
mode:
authorMichal Siedlaczek <michal@siedlaczek.me>2024-01-25 17:21:11 -0500
committerRobin Jarry <robin@jarry.cc>2024-01-25 23:32:56 +0100
commit0a0ab6da9e2644371041c4246eac91f9fa18514f (patch)
treebc90370ce644bc7a3316ed1463d94985e7e1d625 /config/accounts.go
parent21f38698bd58b796e53ed5e9f8f11925f48331b3 (diff)
downloadaerc-0a0ab6da9e2644371041c4246eac91f9fa18514f.tar.gz
config: print file path in error message
In case of a config parsing error, print the file path of the file in which the error occurred. Fixes: https://todo.sr.ht/~rjarry/aerc/218 Signed-off-by: Michal Siedlaczek <michal@siedlaczek.me> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'config/accounts.go')
-rw-r--r--config/accounts.go32
1 files changed, 20 insertions, 12 deletions
diff --git a/config/accounts.go b/config/accounts.go
index 1afa77c4..ac0a5444 100644
--- a/config/accounts.go
+++ b/config/accounts.go
@@ -120,18 +120,7 @@ const (
var Accounts []*AccountConfig
-func parseAccounts(root string, accts []string, filename string) error {
- if filename == "" {
- filename = path.Join(root, "accounts.conf")
- err := checkConfigPerms(filename)
- if errors.Is(err, os.ErrNotExist) {
- // No config triggers account configuration wizard
- return nil
- } else if err != nil {
- return err
- }
- }
-
+func parseAccountsFromFile(root string, accts []string, filename string) error {
log.Debugf("Parsing accounts configuration from %s", filename)
file, err := ini.LoadSources(ini.LoadOptions{
@@ -188,6 +177,25 @@ If you want to disable STARTTLS, append +insecure to the schema.
return nil
}
+func parseAccounts(root string, accts []string, filename string) error {
+ if filename == "" {
+ filename = path.Join(root, "accounts.conf")
+ err := checkConfigPerms(filename)
+ if errors.Is(err, os.ErrNotExist) {
+ // No config triggers account configuration wizard
+ return nil
+ } else if err != nil {
+ return err
+ }
+ }
+
+ if err := parseAccountsFromFile(root, accts, filename); err != nil {
+ return fmt.Errorf("%s: %w", filename, err)
+ }
+
+ return nil
+}
+
func ParseAccountConfig(name string, section *ini.Section) (*AccountConfig, error) {
account := AccountConfig{
Name: name,