gf/geg/other/try-catch.go

23 lines
349 B
Go
Raw Normal View History

package main
import (
2019-04-03 00:03:46 +08:00
"github.com/gogf/gf/g"
"github.com/gogf/gf/g/os/glog"
)
func main() {
2019-04-03 00:03:46 +08:00
g.TryCatch(func() {
2019-06-03 20:58:30 +08:00
glog.Println("hello")
2019-04-03 00:03:46 +08:00
g.Throw("exception")
2019-06-03 20:58:30 +08:00
glog.Println("world")
})
g.TryCatch(func() {
glog.Println("hello")
g.Throw("exception")
glog.Println("world")
2019-04-03 00:03:46 +08:00
}, func(exception interface{}) {
glog.Error(exception)
})
}