try.go raw

   1  package panics
   2  
   3  // Try executes f, catching and returning any panic it might spawn.
   4  //
   5  // The recovered panic can be propagated with panic(), or handled as a normal error with
   6  // (*panics.Recovered).AsError().
   7  func Try(f func()) *Recovered {
   8  	var c Catcher
   9  	c.Try(f)
  10  	return c.Recovered()
  11  }
  12