github gruntwork-io/terratest v0.28.0

latest releases: v0.46.14, v0.46.13, v0.46.12...
3 years ago

Modules affected

  • shell [BACKWARDS INCOMPATIBLE CHANGE]

Description

Updated the shell package to wrap errors with ErrWithCmdOutput so that (a) instead of an unhelpful "FatalError{Underlying: exit status 1}" error message, you now see the stderr output in the error message and (b) you can now programmatically retrieve the stderr stream from errors too.

Migration guide

For most use cases, no changes will be necessary; you'll just get clearer error messages!

However, if you were programmatically using the error returned from shell commands, the type of the error returned and the message within are now different. You can get back the original, underlying error as follows:

err := RunCommandE(t, cmd)
if err != nil {
  errWithOutput, isErrWithOutput := err.(shell.ErrWithCmdOutput)
  if isErrWithOutput {
    // Get the original, underlying error
    underlying = errWithOutput.Underlying
  }
}

Special thanks

Special thanks to @tommyknows for the contribution!

Related links

Don't miss a new terratest release

NewReleases is sending notifications on new releases.