From d743fd7310b767ad26fc0c13353efa94dadc8f62 Mon Sep 17 00:00:00 2001 From: René 'Necoro' Neumann Date: Sat, 22 Apr 2023 22:36:44 +0200 Subject: Improve error handling --- pkg/config/yaml.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'pkg/config/yaml.go') diff --git a/pkg/config/yaml.go b/pkg/config/yaml.go index 3050825..3134f84 100644 --- a/pkg/config/yaml.go +++ b/pkg/config/yaml.go @@ -119,7 +119,7 @@ func (cfg *Config) parse(in io.Reader) error { cfg.fixGlobalOptions(parsedCfg.GlobalConfig) if err := buildFeeds(parsedCfg.Feeds, []string{}, cfg.Feeds, &cfg.FeedOptions, cfg.AutoTarget, &cfg.Target); err != nil { - return fmt.Errorf("while parsing: %w", err) + return err } return nil @@ -200,6 +200,12 @@ func buildFeeds(cfg []configGroupFeed, target []string, feeds Feeds, if _, ok := feeds[name]; ok { return fmt.Errorf("Duplicate Feed Name '%s'", name) } + if len(f.Group.Feeds) > 0 { + return fmt.Errorf("Feed '%s' tries to also be a group.", name) + } + if f.Feed.Url == "" && len(f.Feed.Exec) == 0 { + return fmt.Errorf("Feed '%s' has not specified a URL or an Exec clause.", name) + } opt, unknown := buildOptions(globalFeedOptions, f.Options) @@ -218,6 +224,10 @@ func buildFeeds(cfg []configGroupFeed, target []string, feeds Feeds, } case f.isGroup(): + if len(f.Group.Feeds) == 0 { + log.Warnf("Group '%s' does not contain any feeds.", f.Group.Group) + } + opt, unknown := buildOptions(globalFeedOptions, f.Options) for _, optName := range unknown { -- cgit v1.2.3-70-g09d2