Исходники и презентации
This commit is contained in:
15
lessons/errors/division_by_zero/main.go
Normal file
15
lessons/errors/division_by_zero/main.go
Normal file
@ -0,0 +1,15 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func divide(lhs, rhs int) {
|
||||
defer func() {
|
||||
fmt.Println("recovered:", recover())
|
||||
}()
|
||||
|
||||
_ = lhs / rhs
|
||||
}
|
||||
|
||||
func main() {
|
||||
divide(1000, 0)
|
||||
}
|
||||
Reference in New Issue
Block a user