Skip to content

Commit 2cffebf

Browse files
committed
add a sentinel error for later
1 parent 535ca93 commit 2cffebf

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

extension/landprovider/land_provider.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,29 @@ package landprovider
22

33
import (
44
"context"
5+
"errors"
6+
"fmt"
57

68
"github.com/uber/submitqueue/entity"
79
)
810

11+
// ErrLandRejected is returned by LandProvider implementations when the land operation
12+
// was attempted but rejected due to the changes themselves (e.g., merge conflict, policy
13+
// violation). This is a terminal failure — retrying will not help.
14+
// Infrastructure errors (network timeout, API unavailable) should be returned as plain
15+
// errors so the consumer can retry.
16+
var ErrLandRejected = errors.New("land rejected")
17+
18+
// IsLandRejected returns true if any error in the error chain is an ErrLandRejected.
19+
func IsLandRejected(err error) bool {
20+
return errors.Is(err, ErrLandRejected)
21+
}
22+
23+
// WrapLandRejected wraps ErrLandRejected with a descriptive reason from the land provider.
24+
func WrapLandRejected(err error) error {
25+
return fmt.Errorf("%w: %w", ErrLandRejected, err)
26+
}
27+
928
// LandEntry pairs a land strategy with the change to land.
1029
// Each entry represents one request's contribution to a batch land operation.
1130
type LandEntry struct {
@@ -22,6 +41,7 @@ type LandProvider interface {
2241
// Land merges the provided changes into the target branch of the given queue.
2342
// The queue identifies the repository and target branch.
2443
// Each entry contains a change and the strategy to use for landing it.
44+
// Returns ErrLandRejected if the land was rejected due to the changes themselves.
2545
Land(ctx context.Context, queue string, entries []LandEntry) (Result, error)
2646
}
2747

0 commit comments

Comments
 (0)