-
-
Save Azamat28/5b2c6f66fc4927a002a2d60044aa9231 to your computer and use it in GitHub Desktop.
Handling every error with intuitive code
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" | |
// Handling every error with intuitive code. | |
func thirdFunction() (error, string) { | |
// Some code ... | |
return nil, "Some string" | |
} | |
func secondFunction() (error, string, int) { | |
_, message := thirdFunction() handle(err, _) (error, string) { | |
// Handle error ... | |
return err, "You can return some string too" | |
} | |
// Some code ... | |
return nil, "Some string", 123 | |
} | |
func firstFunction() { | |
_, message, code := secondFunction() handle(err, message) { | |
// Using returned value: | |
fmt.Println(message) | |
// Handling error ... | |
panic(err) | |
} | |
// Some code ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment