Add recover
This commit is contained in:
19
recovering/recovering.go
Normal file
19
recovering/recovering.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package recovering
|
||||
|
||||
import "fmt"
|
||||
|
||||
func Recover() {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
fmt.Printf("Whew. Recovered from panic %v\n", r)
|
||||
}
|
||||
}()
|
||||
|
||||
doPanic()
|
||||
|
||||
fmt.Printf("I'll never execute >...<")
|
||||
}
|
||||
|
||||
func doPanic() {
|
||||
panic("aaaaaaaaaaahhhhhhhhhh sjdnsjdnsdjnsd")
|
||||
}
|
||||
Reference in New Issue
Block a user