-
Notifications
You must be signed in to change notification settings - Fork 9
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
acl: add ACL hostcalls #146
Conversation
Note we can't merge this or run any tests until we have a viceroy release including fastly/Viceroy#438 |
// Not an error; we shouldn't get here | ||
return fmt.Errorf("%w (%s)", ErrUnexpected, err) | ||
case fastly.ACLErrorNoContent: | ||
return ErrNoContent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the context of Handle.Lookup
, I wonder if something like ErrNoMatch
would be more easily understood?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So replace ErrNoContent
with a new error ErrNoMatch
which improves the semenatic match but pulls it farther away from the underlying response code (and Rust SDK I guess).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, agree that it pulls it further from the underlying response code. The Rust SDK uses Option<Response>
with None
when there's no match.
I think ErrNoContent
is fine, but wanted to ask in case we could think of anything better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other way to represent "not found" would be to return a pointer to the entry, or a nil pointer (and no error) if it's not found. That puts the onus on the user, but they're already checking for error (and in fact maybe this is "nicer" since it doesn't conflate an error and a success-not-found case.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think using a pointer/nil could work and agree that it's not conflating errors with not-found cases. One final alternative would be to return something like:
(r Result, ok bool, err error)
where ok is false in the not-found case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rethinking this; I think I'm going to stick with returning an error. For example, Go's database/sql
package returns ErrNoRows
for query returning no rows. This is the same. And I want to stick with the error name in the wit file for consistency (and also in case things change in the future we won't end up in a situation where our SDK code drifts more from the underlying host calls.)
eac0cdb
to
90ebb49
Compare
No description provided.