-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Fix/error handling in user controller.js #2772
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
Fix/error handling in user controller.js #2772
Conversation
The changes to the function look good. You’ve changed the signature of the function so that it no longer accepts a callback as an argument. So you need to make sure that you have updated all the places where this function is used so that the work with an async/promise call instead of passing a callback. |
Please assigned this issue to me @lindapaiste as i have opened the issue and not @Mubashirshariq |
@lindapaiste i have deleted the the findUserbyUsername function used directly findbyusername in aws_controller.js and added some neccessary checks |
So what? |
Please check your facts when u say the solution is provided by an 'Indian youtuber' |
I don't know why there's drama. It's really not necessary. Open source code is a communal effort where we all build off of each other's code and ideas. It is not a competition. When I looked at this a few days ago there were 3 PRs but none of them solved the issue completely. At that time I went and assigned the issue to @BrawlerXull as they had opened the issue and it was still unresolved. Since then @Mubashirshariq revised their PR and changed their approach. It looks a lot better now, as we are returning proper descriptive API errors when encountering problems. I still need to run the code and make sure it works properly at run-time but the code looks right so I'm considering it "solved". |
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.
Looks great, I love that you ate using different error codes depending on what the problem is.
Fixes #2762
Changes:
Used promises to handle the asynchronous operation and use async/await for better readability.
Used try-catch blocks to catch any errors that occur during the operation and handle them gracefully.