Created
August 30, 2018 17:21
-
-
Save pdk/ea6851f25ce5bf7c17b63dd11e614b3a to your computer and use it in GitHub Desktop.
chaining error checks
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 DoSomethingComplicated() error { | |
makro checkErrAlpha(..., err error) ... { | |
if err != nil && IsSpecificErrorType(err) { | |
return fmt.Errorf("specific error happened: %s", err) | |
} | |
} | |
makro checkErrBeta(..., err error) ... { | |
checkErrAlpha(..., err) | |
if err != nil { | |
return fmt.Errorf("some general error happened: %s", err) | |
} | |
} | |
i, j := checkErrBeta(MoreOtherThings()) | |
x, y := checkErrAlpha(SomeOtherCall()) | |
return nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment