Исходники и презентации
This commit is contained in:
27
lessons/errors/panic_rethrow/main.go
Normal file
27
lessons/errors/panic_rethrow/main.go
Normal file
@ -0,0 +1,27 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func process2() {
|
||||
defer func() {
|
||||
e := recover()
|
||||
fmt.Println("#2 recovered:", e)
|
||||
panic(e)
|
||||
}()
|
||||
|
||||
panic("error")
|
||||
}
|
||||
|
||||
func process1() {
|
||||
defer func() {
|
||||
fmt.Println("#1 recovered:", recover())
|
||||
}()
|
||||
|
||||
process2()
|
||||
}
|
||||
|
||||
func main() {
|
||||
process1()
|
||||
}
|
||||
Reference in New Issue
Block a user