github.com/itsabgr/go-handy@v0.0.0-20220724000257-022d51f2b9c6/catch.go (about) 1 package handy 2 3 //Catch call fn with recovered value is it's not nil 4 func Catch[T any](fn func(recovered T)) { 5 recovered := recover() 6 if recovered != nil { 7 fn(Cast[T](recovered)) 8 } 9 }