Исходники и презентации
This commit is contained in:
21
lessons/errors/panic/main.go
Normal file
21
lessons/errors/panic/main.go
Normal file
@ -0,0 +1,21 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func process() {
|
||||
fmt.Println("first")
|
||||
panic("error from process")
|
||||
fmt.Println("second")
|
||||
}
|
||||
|
||||
func main() {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
fmt.Println("recover:", r)
|
||||
}
|
||||
}()
|
||||
|
||||
process()
|
||||
}
|
||||
Reference in New Issue
Block a user