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
Discussion: Should we error here? #185
Comments
If by caller you mean the ultimate consumer of the API, then yes, if I do a GetXByLabel and label does not exist I need a NotFound class of error. Same as a 404 not found on a website. |
I agree that the caller of But I'm not so sure about the callers of the complimentary method which returns a slice. "give me everything matching With the way we're currently using it, there's no difference because the two methods are tightly coupled. Moving the check to here feels slightly more correct. |
getByLabel (or the public function) should return , err for none or multiple. I think we share code where both "get me everything matching this" and "get me one thing matching this" where the code raises no errors for the first and does error checks for the second. I believe specifically for property sets, you cannot create more than one with the same name. |
Did you mean "getByLabels" here? This discussion is mostly just pedantry. I'm looking at it purely from the perspective of "looking only at the function signature, does this function do what I expect?" Thinking practically, we should probably deprecate all of the public
This is version dependent. Versions we have marked as "supported" do allow this. |
|
I see the confusion now. Your previous comment used the same function name twice:
...and I added additional confusing by "fixing it" wrongly in my reply. The missing distinction here isn't "label" vs. "labels", but "thing" vs. "things". So, I think you originally meant this?
|
Yes that. I missed out the s
…On Fri, Jan 12, 2024 at 12:02 PM chrismarget-j ***@***.***> wrote:
I see the confusion now.
Your previous comment used the same function name twice:
*getByLabel* (or the public function) should return , err for none or
multiple.
*getByLabel* should return [] empty list, single list or multiple in the
list, with potentially no error at all.
...and I added additional confusing by "fixing it" wrongly in my reply.
The missing distinction here isn't "label" vs. "labels", but "thing" vs.
"things".
So, I think you originally meant this?
getThingByLabel (or the public function) should return , err for none or
multiple.
getThing*s*ByLabel should return [] empty list, single list or multiple
in the list, with potentially no error at all.
—
Reply to this email directly, view it on GitHub
<#185 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AARW4WZV4PWM7HEN2FXBJV3YOFUAVAVCNFSM6AAAAABBYGCEQ6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBZGY2TEOJRHA>
.
You are receiving this because you were assigned.Message ID:
***@***.***>
|
getPropertySetsByLabel()
returns an error if no matching property sets are found.Should it?
It occurs to me that any expectation about the result count should fall to the caller, rather than to this function.
We probably have this pattern in many of the
get<things>ByLabel()
functions, I just happened to notice it here because I was using this code as a template for something else.https://github.com/Juniper/apstra-go-sdk/blob/41d1f60c196d9efdec83e1b8b0e354c93e9d9f0f/apstra/api_property_sets.go#L119C1-L125C1
The text was updated successfully, but these errors were encountered: