Created
March 5, 2021 11:30
-
-
Save madmag77/a5f1cd53de30c7ab405f2c7dcfacb03b to your computer and use it in GitHub Desktop.
Dart article] Example of exception in Go
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
func Sqrt(f float64) (float64, error) { | |
if f < 0 { | |
return 0, errors.New("math: square root of negative number") | |
} | |
// implementation | |
} | |
f, err := Sqrt(-1) | |
if err != nil { | |
fmt.Println(err) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment