repl.it
@MayankGupta5/

panic_defer_recover

Go

No description

fork
loading
Files
  • main.go
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package main

import "fmt"

func recoveryFunction() {
  if recoveryMessage := recover(); recoveryMessage != nil {
    fmt.Println(recoveryMessage)
  }
  fmt.Println("This is recovery function...")
}

func executePanic() {
  defer recoveryFunction()
  panic("This is Panic Situation")
  fmt.Println("The function executes Completely")  
}

func main() {
  executePanic()
  fmt.Println("Main block is executed completely...")
}