1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2025-11-23 21:44:44 +02:00

Use modern error handling and enforce it via lint (#1327)

Co-authored-by: Anbraten <anton@ju60.de>
This commit is contained in:
6543
2023-02-02 00:08:02 +01:00
committed by GitHub
parent c73b1ecf2a
commit 18d3139e9e
37 changed files with 156 additions and 157 deletions

View File

@@ -16,6 +16,7 @@ package local
import (
"context"
"errors"
"fmt"
"io"
"os"
@@ -133,11 +134,14 @@ func (e *local) Exec(ctx context.Context, step *types.Step) error {
func (e *local) Wait(context.Context, *types.Step) (*types.State, error) {
err := e.cmd.Wait()
ExitCode := 0
if eerr, ok := err.(*exec.ExitError); ok {
ExitCode = eerr.ExitCode()
var execExitError *exec.ExitError
if errors.As(err, &execExitError) {
ExitCode = execExitError.ExitCode()
// Non-zero exit code is a pipeline failure, but not an agent error.
err = nil
}
return &types.State{
Exited: true,
ExitCode: ExitCode,