-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Fixed Improvements to error messaging issue #1091 #1166
Closed
Closed
Changes from 10 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
6057930
Fixed Improvements to error messaging issue #1091
devkashan1 e97b93c
Linter fixes, added 2 spaces.
devkashan1 30ad015
Fixed a couple of spaces
devkashan1 687f758
Fixed a few move lines
devkashan1 f6c220e
Fixed spaces issues.
devkashan1 9c4a69e
property shorthand fixed
devkashan1 c03e278
object-shorthand fixed
devkashan1 3f15c26
fixed the error messages
devkashan1 8a0b114
removed type
devkashan1 d5a16a0
typo fixed and changed the description of function
devkashan1 0496c93
Moved & changed the function in Session.js
devkashan1 677448f
moved the function to API.js
devkashan1 5212bc6
Linter fixes
devkashan1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const errorMessages = [ | ||
{ | ||
errorCode: 401, | ||
errorMessage: 'Incorrect login or password. Please try again.', | ||
}, | ||
{ | ||
errorCode: 402, | ||
errorMessage: | ||
'You have 2FA enabled on this account. Please sign in using your email or phone number.', | ||
}, | ||
{ | ||
errorCode: 403, | ||
errorMessage: | ||
'Invalid login or password. Please try again or reset your password.', | ||
}, | ||
{ | ||
errorCode: 404, | ||
errorMessage: | ||
'We were unable to change your password. This is likely due to an expired password reset link in an old password reset email. We have emailed you a new link so you can try again. Check your Inbox and your Spam folder; it should arrive in just a few minutes.', | ||
}, | ||
{ | ||
errorCode: 405, | ||
errorMessage: | ||
'You do not have access to this application. Please add your GitHub username for access.', | ||
}, | ||
{ | ||
errorCode: 413, | ||
errorMessage: 'Your account has been locked.', | ||
}, | ||
]; | ||
export default errorMessages; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import _ from 'lodash'; | ||
import errorMessages from './errorMessages'; | ||
|
||
/** | ||
* It's function to print handle error messages in the context of Authenticate. | ||
* | ||
* @param {String} error | ||
* @returns {String} | ||
*/ | ||
function getErrorMessage(error) { | ||
const code = error.split(' ')[0]; | ||
if (!_.isEmpty(code)) { | ||
const errorMessage = _.filter(errorMessages, {errorCode: +code.trim()}); | ||
if (!_.isEmpty(errorMessage)) { | ||
return errorMessage[0].errorMessage; | ||
} | ||
} | ||
return error; | ||
} | ||
export default getErrorMessage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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.
Typo?
print handle error messages
is awkward. Probably should be either/or.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.
@deetergp Okay, I think, It will be better.
This function is handling error messages for the Authentication.
else can you advise on it?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.
At the end of the day, shouldn't your naming explain the "what" and your docs and comments explain the "why"? Like shouldn't function be called
getFriendlyErrorMessage
and the doc comment should briefly summarize the reason we need the function likeDisplay a user-friendly message in the UI when the API returns an authentication error
.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.
@deetergp Okay, Should we change with this
Display a error message in the UI when the API returns an authentication error.
?If it works, please let me know. I'll change it. Thanks
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.
@devkashan1 I meant to move this logic to the context of
Authenticate
(in src/libs/Api.js) since that's the only spot where it's relevant.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.
@yuwenmemon Thanks for the clarification. I just have pushed the changes. You can verify now.