Advertisement
cwchen

[Go] Recover demo.

Oct 28th, 2017
507
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.23 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.     "fmt"
  5. )
  6.  
  7. func main() {
  8.     defer func() {
  9.         err := recover()
  10.         if err != nil {
  11.             fmt.Println("Recover from panic")
  12.         }
  13.     }()
  14.  
  15.     panic("Some error")
  16.  
  17.     // It didn't occur.
  18.     fmt.Println("More message")
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement