-
Notifications
You must be signed in to change notification settings - Fork 444
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
Add error msg in notification #594
Conversation
Add the API response error message in the frontend notification box. Signed-off-by: Xichen Pan <xichen.pan@gmail.com>
Agree to modify, and suggest not displaying the API information above, as it is meaningless for the user. |
src/dashboard/src/utils/request.js
Outdated
const errortext = ( | ||
<> | ||
{codeMessage[response.status] || response.statusText} <br /> | ||
{data.msg[0]} |
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.
Can you confirm that there must be data in the incorrect response information? There must be msg in the data, and msg must be an array. If the format cannot be determined, it is recommended to increase the judgment, otherwise the front-end may encounter exceptions.
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.
Does that mean we need to use if
to check the response content?
If there is no msg or msg is not an array, we display the default message?
I think most of the backend error handlers send data msg array.
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.
now add condition check:
{data && data.msg && Array.isArray(data.msg) && data.msg.length > 0 && data.msg[0]}
Signed-off-by: Xichen Pan <xichen.pan@gmail.com>
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.
OK
Add the API response error message in the frontend notification box.
For #593
Signed-off-by: Xichen Pan xichen.pan@gmail.com