tgerrors

package
v2.7.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 15, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const ChangeExitCode = 2

ChangeExitCode is the exit code returned on terraform plan with changes

Variables

This section is empty.

Functions

func Assert

func Assert(test bool, format interface{}, args ...interface{})

Assert raises a panic with the formatted messsage if the test is not true.

func IsError

func IsError(actual error, expected error) bool

IsError returns true if actual is the same type of error as expected. This method unwraps the given error objects (if they are wrapped in objects with a stacktrace) and then does a simple equality check on them.

func PrintErrorWithStackTrace

func PrintErrorWithStackTrace(err error) string

PrintErrorWithStackTrace converts the given error to a string, including the stack trace if available

func Recover

func Recover(onPanic func(error))

Recover is a method that tries to recover from panics, and if it succeeds, calls the given onPanic function with an error that explains the cause of the panic. This function should only be called from a defer statement.

func Unwrap

func Unwrap(err error) error

Unwrap if the given error is a wrapper that contains a stacktrace, unwrap it and return the original, underlying error. In all other cases, return the error unchanged

func WithStackTrace

func WithStackTrace(err error) error

WithStackTrace wraps the given error in an Error type that contains the stack trace. If the given error already has a stack trace, it is used directly. If the given error is nil, return nil.

func WithStackTraceAndPrefix

func WithStackTraceAndPrefix(err error, message string, args ...interface{}) error

WithStackTraceAndPrefix wraps the given error in an Error type that contains the stack trace and has the given message prepended as part of the error message. If the given error already has a stack trace, it is used directly. If the given error is nil, return nil.

Types

type Error

type Error = goerrors.Error

Error is simply an alias to the go-errors Error type

type IErrorCode

type IErrorCode interface {
	ExitStatus() (int, error)
}

IErrorCode represents interface to determine if we can retrieve an exit status from an error

type PlanWithChanges

type PlanWithChanges struct{}

PlanWithChanges represents the situation where terraform plan return 2 to indicate that there are changes

func (PlanWithChanges) Error

func (err PlanWithChanges) Error() string

func (PlanWithChanges) ExitStatus

func (err PlanWithChanges) ExitStatus() (int, error)

ExitStatus returns the exit code associated with this error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL