Skip to content
Discussion options

You must be logged in to vote

ah I think I'm tracking now. I cooked this up and tried it on my machine:

type ResultEnum uint8

const (
	Success ResultEnum = iota
	InternalFailure
	UserFailure
	UserPanic
)

type Result struct {
	Result  ResultEnum
	Message string
	Panic   any
}

func Execute(fn func(), sprocket int) {
	c := make(chan Result)
	go execute(c, fn, sprocket)
	result := <-c
	switch result.Result {
	case Success:
		return
	case UserFailure:
		return // a user failure will have already registered a failure with Ginkgo
	case InternalFailure, UserPanic:
		Fail(result.Message)
	}
}

func execute(c chan Result, fn func(), sprocket int) {
	defer func() {
		if r := recover(); r != nil {
			switch result := r.(type) …

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
1 reply
@thediveo
Comment options

Comment options

You must be logged in to vote
4 replies
@thediveo
Comment options

@onsi
Comment options

onsi May 9, 2026
Maintainer

@thediveo
Comment options

@onsi
Comment options

onsi May 11, 2026
Maintainer

Answer selected by thediveo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants