example of a defer that uses named error return params
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 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