kubernetes/test/utils/ktesting/errorcontext.go

// WithError creates a context where test failures are collected and stored in
// the provided error instance when the caller is done. Use it like this:
//
//	func doSomething(tCtx ktesting.TContext) (finalErr error) {
//	     tCtx, finalize := WithError(tCtx, &finalErr)
//	     defer finalize()
//	     ...
//	     tCtx.Fatal("some failure")
//
// Any error already stored in the variable will get overwritten by finalize if
// there were test failures, otherwise the variable is left unchanged.
// If there were multiple test errors, then the error will wrap all of
// them with errors.Join.
//
// Test failures are not propagated to the parent context.
func WithError(tCtx TContext, err *error) (TContext, func()) {}

type errorContext

func (eCtx *errorContext) finalize(err *error) {}

func (eCtx *errorContext) Error(args ...any) {}

func (eCtx *errorContext) Errorf(format string, args ...any) {}

func (eCtx *errorContext) Fail() {}

func (eCtx *errorContext) FailNow() {}

func (eCtx *errorContext) Failed() bool {}

func (eCtx *errorContext) Fatal(args ...any) {}

func (eCtx *errorContext) Fatalf(format string, args ...any) {}

func (eCtx *errorContext) CleanupCtx(cb func(TContext)) {}

func (eCtx *errorContext) Expect(actual interface{}

func (eCtx *errorContext) ExpectNoError(err error, explain ...interface{}

func (eCtx *errorContext) Logger() klog.Logger {}

type fatalWithError

const failed

var errFailedWithNoExplanation