Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runner: Deprecate EnsureNoError helper #236

Merged
merged 1 commit into from
Mar 6, 2023
Merged

Conversation

wata727
Copy link
Member

@wata727 wata727 commented Feb 26, 2023

Closes #196

This PR deprecates runner.EnsureNoError. Instead, use errors.Is() to determine if the error should be ignored:

EDIT: The following example fix has been retracted. Please see #246 for more details.

// before
var val string
err := runner.EvaluateExpr(expr, &val, nil)
err = runner.EnsureNoError(err, func () error {
  // Test values
})
if err != nil {
  return err
}

// after
var val string
err := runner.EvaluateExpr(expr, &val, nil)
if err != nil {
  if errors.Is(err, tflint.ErrUnknownValue) || errors.Is(err, tflint.ErrNullValue) || errors.Is(err, tflint.Sensitive) {
    return nil
  }
  return err
}
// Test values

The above is a simple replacement example, but we recommend that you reconsider whether you should ignore the above errors. For example, instead of ignoring null, you may want to raise an error.

See #196 for a discussion on how it came to be deprecated.

EnsureNoError is not removed at this time, but it will be removed in a future version, so early migration is recommended.

@wata727 wata727 merged commit 7b23e20 into master Mar 6, 2023
@wata727 wata727 deleted the deprecate_ensure_no_errors branch March 6, 2023 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

EnsureNoError is a bad interface
1 participant