aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXe Iaso <me@xeiaso.net>2025-03-15 15:25:47 -0400
committerXe Iaso <me@xeiaso.net>2025-03-15 15:27:07 -0400
commit653426318b70278240ad483d4c4723399df016be (patch)
treecb1153ea92ebddcb775a67178e282143aea9b06f
parent4755ba2b524f50f634a186ea5440ed2d6daa868e (diff)
downloadx-653426318b70278240ad483d4c4723399df016be.tar.xz
x-653426318b70278240ad483d4c4723399df016be.zip
cmd/anubis/internal/config: properly use errors.Join
Signed-off-by: Xe Iaso <me@xeiaso.net>
-rw-r--r--cmd/anubis/internal/config/config.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/cmd/anubis/internal/config/config.go b/cmd/anubis/internal/config/config.go
index b67db77..8a86eef 100644
--- a/cmd/anubis/internal/config/config.go
+++ b/cmd/anubis/internal/config/config.go
@@ -28,25 +28,25 @@ var (
)
func (b Bot) Valid() error {
- var err error
+ var errs []error
if b.Name == "" {
- err = errors.Join(err, ErrBotMustHaveName)
+ errs = append(errs, ErrBotMustHaveName)
}
if b.UserAgentRegex == nil && b.PathRegex == nil {
- err = errors.Join(err, ErrBotMustHaveUserAgentPathOrBoth)
+ errs = append(errs, ErrBotMustHaveUserAgentPathOrBoth)
}
switch b.Action {
case RuleAllow, RuleChallenge, RuleDeny:
// okay
default:
- err = errors.Join(err, fmt.Errorf("%w: %q", ErrUnknownAction, b.Action))
+ errs = append(errs, fmt.Errorf("%w: %q", ErrUnknownAction, b.Action))
}
- if err != nil {
- return fmt.Errorf("config: bot entry for %q is not valid: %w", b.Name, err)
+ if errs != nil {
+ return fmt.Errorf("config: bot entry for %q is not valid: %w", b.Name, errors.Join(errs...))
}
return nil