RosettaCodeData/Task/Exceptions/Go/exceptions.go

23 lines
377 B
Go
Raw Permalink Normal View History

2013-04-10 16:57:12 -07:00
package main
import "fmt"
2015-02-20 00:35:01 -05:00
func foo() int {
fmt.Println("let's foo...")
defer func() {
if e := recover(); e != nil {
fmt.Println("Recovered from", e)
}
}()
var a []int
a[12] = 0
fmt.Println("there's no point in going on.")
panic("never reached")
panic(fmt.Scan) // Can use any value, here a function!
2013-04-10 16:57:12 -07:00
}
func main() {
2015-02-20 00:35:01 -05:00
foo()
fmt.Println("glad that's over.")
2013-04-10 16:57:12 -07:00
}