You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By reading the source code and the existing documentation (e.g. README.md or code docstrings) I understand that WithDetail() and WithHint() can be used in the same way.
README states for both:
when to use: need to embark a message string to output when the error is presented to a human.
The source code hintdetail/with_detail.go and hintdetail/with_hint.go is also essentially identical.
So what is the difference? Maybe this library is trying to be non-prescriptive and giving its users freedom to use these functions and types as it suits them, but it is giving two mechanisms for apparently solving the same problem. Giving some guidance how this was originally intended is probably valuable to make usage more uniform and thereby make understanding and contributing to other people's code easier.
If I check the CockroachDB source code for instances of these functions I get the impression that WithDetail() is meant more for internal use to augment errors with additional information for debugging whereas WithHint() is meant for giving end users hints about what is wrong with the data they provided. But I might be misunderstanding or cherry-picking examples.
e.g.
err:=errors.WithDetail(errors.Newf(
"attempting to discard the zone configuration of a multi-region entity"),
"discarding a multi-region zone configuration may result in sub-optimal performance or behavior",
)
By reading the source code and the existing documentation (e.g. README.md or code docstrings) I understand that
WithDetail()
andWithHint()
can be used in the same way.README states for both:
The source code
hintdetail/with_detail.go
andhintdetail/with_hint.go
is also essentially identical.So what is the difference? Maybe this library is trying to be non-prescriptive and giving its users freedom to use these functions and types as it suits them, but it is giving two mechanisms for apparently solving the same problem. Giving some guidance how this was originally intended is probably valuable to make usage more uniform and thereby make understanding and contributing to other people's code easier.
If I check the CockroachDB source code for instances of these functions I get the impression that
WithDetail()
is meant more for internal use to augment errors with additional information for debugging whereasWithHint()
is meant for giving end users hints about what is wrong with the data they provided. But I might be misunderstanding or cherry-picking examples.e.g.
How to improve
What I suggest is making some distinction in the README "Available wrapper constructors" section and in the
WithDetail()
andWithHint()
docstring.The text was updated successfully, but these errors were encountered: