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

Add error msg in notification #594

Merged
merged 2 commits into from
Feb 24, 2024
Merged

Conversation

xichen1
Copy link
Member

@xichen1 xichen1 commented Jan 18, 2024

Add the API response error message in the frontend notification box.

For #593

image

Signed-off-by: Xichen Pan xichen.pan@gmail.com

Add the API response error message in the frontend notification box.

Signed-off-by: Xichen Pan <xichen.pan@gmail.com>
@xichen1 xichen1 requested a review from a team January 18, 2024 07:02
@fengyangsy
Copy link
Collaborator

Agree to modify, and suggest not displaying the API information above, as it is meaningless for the user.

const errortext = (
<>
{codeMessage[response.status] || response.statusText} <br />
{data.msg[0]}
Copy link
Collaborator

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.

Copy link
Member Author

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.

Copy link
Member Author

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>
@xichen1 xichen1 requested a review from fengyangsy February 24, 2024 02:38
Copy link
Collaborator

@fengyangsy fengyangsy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

@xichen1 xichen1 merged commit ca89f9a into hyperledger:main Feb 24, 2024
3 checks passed
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

Successfully merging this pull request may close these issues.

2 participants