Panic Recover

Python

  1. try:
  2. raise Exception('Shit')
  3. except Exception as e:
  4. print "error was:", e

Go

  1. package main
  2.  
  3. import "fmt"
  4.  
  5. func main() {
  6.  
  7. // Running this will print out:
  8. // error was: Shit!
  9. defer func() {
  10. fmt.Println("error was:", recover())
  11. }()
  12. panic("Shit!")
  13. }