Skip to content
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

Check for errors when applying modifiers #118

Open
lestrozi opened this issue Aug 2, 2018 · 2 comments
Open

Check for errors when applying modifiers #118

lestrozi opened this issue Aug 2, 2018 · 2 comments

Comments

@lestrozi
Copy link
Contributor

lestrozi commented Aug 2, 2018

It would be nice to check for errors when applying modifiers.

For instance:

- solicit = mod(solicit)
+ solicit, err = mod(solicit)
+ if err != nil { return ..., err }
@insomniacslk
Copy link
Owner

This probably requires a more complex Modifier interface, because modifiers can be applied in different moments, in different functions, that may or may not return an error. This will probably require an error channel. E.g. in Exchange functions, the modifiers are applied twice, and we would not be able to distinguish where it failed exactly (if we even want to).

A possible interface could be type Modifier func(e chan<- error) DHCPv6, where the caller passes either a valid error channel, or nil, and the modifier will write to that channel if it's not nil. This is still a bit cumbersome but it seems the simplest interface to me. Any ideas?

@lestrozi
Copy link
Contributor Author

lestrozi commented Aug 3, 2018

I'm not very familiar with Go.. this looks like a classic use for exceptions but I don't see a good way to do that in Go. The error channel is a good idea, but it's kinda complex.
I think I will change my suggestion to just panic if a modifier fails to apply. The rationale is that 1) I can't think on a situation where getting an error applying a modifier is not a bug (can you?) and 2) I think it's ok to panic when there's a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants