Created
August 28, 2016 14:41
-
-
Save hiraq/4adbed71a6b25212d72acd1a1a9cda6b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func Catch() { | |
if r := recover(); r != nil { | |
fmt.Println(fmt.Sprintf("Recovered from : %v", r)) | |
} | |
} | |
func DoPanic() { | |
defer Catch() | |
panic("This is panic") | |
} | |
func main() { | |
DoPanic() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment