Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BailError ¶ added in v3.80.0
BailError is the replacement for Result now that Go supports wrapping errors. It is used to indicate that a computation failed, but that it failed gracefully, i.e. it is not a bug in Pulumi. BailError implements the error interface but will prefix it's error string with BAIL, which if ever seen in user facing messages indicates that a check for bailing was missed. It also blocks `Unwrap` calls, instead to get access to the inner error use the `IsBail` function.
func BailErrorf ¶ added in v3.80.0
BailErrorf is a helper for BailError(fmt.Errorf(...)).
func FprintBailf ¶ added in v3.80.0
FprintBailf writes a formatted string to the given writer and returns a BailError with the same message.
Types ¶
type Result ¶
Result represents the result of a computation that can fail. The Result type revolves around two notions of failure:
1. Computations can fail, but they can fail gracefully. Computations that fail gracefully do so by logging a diagnostic and returning a non-nil "bail" result.
2. Computations can fail due to bugs in Pulumi. Computations that fail in this manner do so by constructing a Result using the `Error`, `Errorf`, or `FromError` constructor functions.
Result is an interface so that it can be nullable. A function returning a pointer Result has the following semantics:
If the result is `nil`, the caller should proceed. The callee believes that the overarching plan can still continue, even if it logged diagnostics.
If the result is non-nil, the caller should not proceed. Most often, the caller should return this Result to its caller.
At the highest level, when a function wishes to return only an `error`, the `Error` member function can be used to turn a nullable `Result` into an `error`.
func Bail ¶
func Bail() Result
Bail produces a Result that represents a computation that failed to complete successfully but is not a bug in Pulumi.
func Error ¶
Error produces a Result that represents an internal Pulumi error, constructed from the given message.
func Errorf ¶
Errorf produces a Result that represents an internal Pulumi error, constructed from the given format string and arguments.
func FromError ¶
FromError produces a Result that wraps an internal Pulumi error. Do not call this with a 'nil' error. A 'nil' error means that there was no problem, and in that case a 'nil' result should be used instead. If this is called with an error from `BailError` it will discard the inner error of that and return a bail result.
func Merge ¶
Merge combines two results into one final result. It properly respects all three forms of Result (i.e. nil/bail/error) for both results, and combines all sensibly into a final form that represents the information of both.
func WrapIfNonNil ¶
WrapIfNonNil returns a non-nil Result if [err] is non-nil. Otherwise it returns nil.