-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Emit returning errors #62
Comments
License: MIT Signed-off-by: Kevin Atkinson <[email protected]>
Proposal: Entirely separate errors and values.
This would also solve #31 as, in the HTTP case, RCP-level errors would be sent via trailer headers only (never inline as content). |
On that note, it would be really nice if func(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment) {
err := doSth()
if err != nil {
re.SetError(err, cmdkit.ErrNormal)
return
}
re.Emit("cool")
}
// vs
func(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment) error {
err := doSth()
if err != nil {
return err
}
re.Emit("cool")
return nil
} |
May I propose func(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment) error {
err := doSth()
if err != nil {
return err
}
return re.Emit("cool")
} That way we don't lose the error and the code is still clean. ping @whyrusleeping |
I think it provides a pretty poor UX to have Emit return errors. It complicates the calling code a bit (what do we even do with the errors? we cant use SetError). Lets discuss how to address this.
The text was updated successfully, but these errors were encountered: