From 6dec97cc6923dc146a96ed96bdcd8dfe0e7ed811 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Mon, 20 Feb 2023 22:08:16 +0100 Subject: [PATCH] fix: fix error handling (#131) --- cmd/drone-ansible/main.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/cmd/drone-ansible/main.go b/cmd/drone-ansible/main.go index 3155479..75b861b 100644 --- a/cmd/drone-ansible/main.go +++ b/cmd/drone-ansible/main.go @@ -53,11 +53,21 @@ func run(settings *plugin.Settings) cli.ActionFunc { ) if err := plugin.Validate(); err != nil { - return fmt.Errorf("validation failed: %w", err) + //nolint:errorlint + if e, ok := err.(errors.ExitCoder); ok { + return e + } + + return errors.ExitMessagef("validation failed: %w", err) } if err := plugin.Execute(); err != nil { - return fmt.Errorf("execution failed: %w", err) + //nolint:errorlint + if e, ok := err.(errors.ExitCoder); ok { + return e + } + + return errors.ExitMessagef("execution failed: %w", err) } return nil