You've already forked woodpecker
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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user