You have a code with a defined recover function, named panicHandler(). Try to produce a direct panic message to get the message "Second signal handled!" from the panicHandler() function.
Panic and recover
Choose a recover method
Report a typo
Write a program in Go
package main
import "fmt"
func panicHandler() {
signal := recover()
switch signal {
case "first":
fmt.Println("First signal catched!")
case "second":
fmt.Println("Second signal handled!")
default:
fmt.Println("Undefined signal")
}
}
func main() {
defer panicHandler()
panic(?)
}
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.