Created
September 27, 2018 19:25
-
-
Save ChimeraCoder/9fdef30e84ab374b612533ae4fd06873 to your computer and use it in GitHub Desktop.
example of a defer that uses named error return params
This file contains hidden or 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 CalculateThing() (result int, err error) { | |
defer func() { | |
if err != nil { | |
monitoringSrv.HandleErr("CalculateThing", err) | |
} | |
}() | |
var a, b int | |
a, err = doA() | |
if err != nil { | |
return | |
} | |
b, err = doB(a) | |
if err != nil { | |
return | |
} | |
result, err = doC(b) | |
return | |
} | |
func CalculateThing2() (result int, err error) { | |
handle err { | |
monitoringSrv.HandleErr("CalculateThing", err) | |
} | |
a := check doA() | |
b := check doB(a) | |
result = check doC(b) | |
return | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment