Skip to content

Instantly share code, notes, and snippets.

@Azamat28
Last active March 17, 2021 17:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Azamat28/5b2c6f66fc4927a002a2d60044aa9231 to your computer and use it in GitHub Desktop.
Save Azamat28/5b2c6f66fc4927a002a2d60044aa9231 to your computer and use it in GitHub Desktop.
Handling every error with intuitive code
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