github.com/itsabgr/go-handy@v0.0.0-20220724000257-022d51f2b9c6/Box.go (about)

     1  package handy
     2  
     3  //Box call fn and recover a panic and returns recovered value
     4  //go:noinline
     5  func Box(fn func()) (recovered interface{}) {
     6  	defer func() {
     7  		recovered = recover()
     8  	}()
     9  	fn()
    10  	return
    11  }