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

Violation of Single Responsibility Principle: #942

Open
ohrrkan opened this issue Aug 19, 2024 · 0 comments
Open

Violation of Single Responsibility Principle: #942

ohrrkan opened this issue Aug 19, 2024 · 0 comments

Comments

@ohrrkan
Copy link

ohrrkan commented Aug 19, 2024

Some function can throw or return error.

For example 'decodeJWTPayload" can throw an error JWT is not valid: not a JWT structure that will then be throw by setSession.
setSession is define to return an error.

const payload = decodeJWTPayload(currentSession.access_token)

setSession (and other function) should make a choice between throw error or return but not both => it’s not a good practice for a function to sometimes throw an error and at other times return a value indicating an error. This can lead to confusion, inconsistency, and difficulty in understanding how the function behaves for users/developpers and maintenance.

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

1 participant