feat: return errors in exported functions instead of panicking #37
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
👋🏽 hi team
What
This PR proposes braking changes to some of the exported functions⚠️
Namely,
NewSRPClient(),NewSRPServer(), andKDFRFC5054().Concretely, it changes the signature of these methods so that they return an error (a common Go idiom), rather than panicking. This allows consumers of the library to handle the errors gracefully and at their convinience.
What approach did you choose and why?
I identified all the places where we panic. I refactored it to emit an error instead. I then worked my way upwards so that the error gets bubbled up all the way to the exported functions.
What should reviewers focus on?
I believe there is much to be gained from this breaking change:
So the questions I think we should focus on are (if the changes are approved):
If something goes wrong, what are the mitigation strategies?
Consumers of this library can use the previous tag or a commit SHA prior to this PR.
Note that I am not an official collaborator on this repo, so my commits won't trigger CI builds. If you want to see the CI for these commits, see my fork: https://github.com/CamiloGarciaLaRotta/srp/pull/2/commits
Performance Impact
None
Observability
N/A