Hi, I would like to shield my application from any possible panicking by the third-party library. There was an occasion when a third party library crashed my application due to unnecessary panicking. I am thinking of creating a thin wrapper that will also catch any panic into error. How can I do that in Go?
func PanicFunction() { panic("Panic!") } func MustNotPanic() error { defer func(){ if err:=recover(); err!=nil{ //ermm ... how do you return error from here? } }() PanicFunction() } func main(){ if err:=MustNotPanic();err==nil{ fmt.Println("Failed to catch panic") return } fmt.Println("success") } Thanks. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.