File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -17,10 +17,13 @@ type (
1717 // Result is the object that is returned after each step and after running a pipeline.
1818 Result struct {
1919 // Err contains the step's returned error, nil otherwise.
20+ // In an aborted pipeline with ErrAbort it will still be nil.
2021 Err error
2122 // Name is an optional identifier for a result.
2223 // ActionFunc may set this property before returning to help a ResultHandler with further processing.
2324 Name string
25+
26+ aborted bool
2427 }
2528 // Step is an intermediary action and part of a Pipeline.
2629 Step struct {
@@ -144,7 +147,7 @@ func (p *Pipeline) doRun() Result {
144147 if err != nil {
145148 if errors .Is (err , ErrAbort ) {
146149 // Abort pipeline without error
147- return Result {}
150+ return Result {aborted : true }
148151 }
149152 if p .disableErrorWrapping {
150153 return Result {Err : err }
Original file line number Diff line number Diff line change @@ -6,6 +6,8 @@ import "errors"
66var ErrAbort = errors .New ("abort" )
77
88// IsSuccessful returns true if the contained error is nil.
9+ // Aborted pipelines (with ErrAbort) are still reported as success.
10+ // To query if a pipeline is aborted early, use IsAborted.
911func (r Result ) IsSuccessful () bool {
1012 return r .Err == nil
1113}
@@ -14,3 +16,8 @@ func (r Result) IsSuccessful() bool {
1416func (r Result ) IsFailed () bool {
1517 return r .Err != nil
1618}
19+
20+ // IsAborted returns true if the pipeline didn't stop with an error, but just aborted early with ErrAbort.
21+ func (r Result ) IsAborted () bool {
22+ return r .aborted
23+ }
You can’t perform that action at this time.
0 commit comments