package
1.3.48
Repository: https://github.com/sandwich-go/boost.git
Documentation: pkg.go.dev

# README

xpanic

panic 辅助函数

  • error 不为 nil 时, panic
  • true 时,panic
  • try cache panic

例子

Do(func() {
    fmt.Println("Doing something...")
    panic("Something wrong happened!")
}, func(p *Panic) {
    fmt.Println("Caught a panic:", p.Reason)
})

AutoRecover("something", func(){
    // do something
    // if panic, auto execute this function continue.
})

Try(func() {
    WhenErrorAsFmtFirst(err, "%w, %d", 1)
}).Catch(func(err E) {
    fmt.Println(err)
})

Output:

error, 1