result

package
v3.40.2 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2022 License: Apache-2.0 Imports: 3 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TODO

func TODO() error

TODO returns an error that can be used in places that have not yet been adapted to use Results. Their use is intended to be temporary until Results are plumbed throughout the Pulumi codebase.

Types

type Result

type Result interface {
	Error() error
	IsBail() bool
}

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

func Error(msg string) Result

Error produces a Result that represents an internal Pulumi error, constructed from the given message.

func Errorf

func Errorf(msg string, args ...interface{}) Result

Errorf produces a Result that represents an internal Pulumi error, constructed from the given format string and arguments.

func FromError

func FromError(err error) Result

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.

func Merge

func Merge(res1 Result, res2 Result) Result

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

func WrapIfNonNil(err error) Result

WrapIfNonNil returns a non-nil Result if [err] is non-nil. Otherwise it returns nil.

Jump to

Keyboard shortcuts

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