mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-28 01:41:48 -06:00
handle wrapped EvalEarlyExitErrors
This commit is contained in:
parent
477111e6b6
commit
fe9c93b9f9
@ -2,6 +2,7 @@ package terraform
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"sync"
|
||||
|
||||
"github.com/zclconf/go-cty/cty"
|
||||
@ -145,16 +146,34 @@ func (w *ContextGraphWalker) Execute(ctx EvalContext, n GraphNodeExecutable) tfd
|
||||
return nil
|
||||
}
|
||||
|
||||
if _, isEarlyExit := err.(EvalEarlyExitError); isEarlyExit {
|
||||
var diags tfdiags.Diagnostics
|
||||
|
||||
// Handle a simple early exit error
|
||||
if errors.Is(err, EvalEarlyExitError{}) {
|
||||
return nil
|
||||
}
|
||||
|
||||
// we need to see if this wraps only EarlyExitErrors
|
||||
if wrapper, ok := err.(interface{ WrappedErrors() []error }); ok {
|
||||
//WrappedErrors only returns native error values, so we can't extract
|
||||
//them from diagnostics. Just return the whole thing if we have a
|
||||
//combination.
|
||||
errs := wrapper.WrappedErrors()
|
||||
earlyExit := true
|
||||
for _, err := range errs {
|
||||
if err != (EvalEarlyExitError{}) {
|
||||
earlyExit = false
|
||||
}
|
||||
}
|
||||
if len(errs) > 0 && earlyExit {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise, we'll let our usual diagnostics machinery figure out how to
|
||||
// unpack this as one or more diagnostic messages and return that. If we
|
||||
// get down here then the returned diagnostics will contain at least one
|
||||
// error, causing the graph walk to halt.
|
||||
var diags tfdiags.Diagnostics
|
||||
diags = diags.Append(err)
|
||||
return diags
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user