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

🥅(frontend) improve add member form error handling #387

Merged
merged 2 commits into from
Sep 26, 2024

Conversation

daproclaima
Copy link
Collaborator

@daproclaima daproclaima commented Sep 10, 2024

Purpose

The error cause displayed when group creation fails because it already exists uses technical wording as it comes directly from the backend. The front end should capture this error and replace it with a message appealing to the end users.

Proposal

  • Capture the error cause 'Team with this Slug already exists.' returned by POST on api/v1.0.0/teams/ to show 'This name is already used for another group. Please enter another one.' instead.

Before

Before.mp4

After

After.mp4

Closes #293.

@daproclaima daproclaima self-assigned this Sep 10, 2024
@daproclaima daproclaima linked an issue Sep 10, 2024 that may be closed by this pull request
@daproclaima daproclaima force-pushed the feature/group-creation-error branch 2 times, most recently from 572f468 to 08336f2 Compare September 10, 2024 13:39
@daproclaima daproclaima marked this pull request as ready for review September 10, 2024 14:22
Copy link
Collaborator

@AntoLC AntoLC left a comment

Choose a reason for hiding this comment

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

I still find parseAPIError very complicated to replace a string by another string.

I am not sure what is the answer to that: #387 (comment)

@daproclaima
Copy link
Collaborator Author

daproclaima commented Sep 23, 2024

@AntoLC, thanks for the remarks.

I thought of creating this function to reuse it everywhere on APIErrors handling, whether the developer wants to replace an error cause with another message, and/or execute a callback at its detection, and/or show a custom message on 500 error detection.

At the moment, we directly display the 500 error messages on the UI, which may not be the most user-friendly way to explain to the end users that the error is not their fault and that they'd do well reaching out to us so we fix the error.

I used parseAPIError on InputTeamName.tsx to replace a string with another one, as you say, for one of the client errors we already know. I especially wanted to show a custom error message for 500 types of errors.

If I treated only the client error, I would use a more straightforward function.

We should display a message for all forms that helps the user know the next step to fix the error. This is especially true for server errors, which we are responsible for and can only fix if we are contacted.
What do you think?

@daproclaima daproclaima force-pushed the feature/group-creation-error branch 3 times, most recently from 35afca4 to e4a73f1 Compare September 26, 2024 15:05
- translate known errors, including already existing
group error, and directly display the other ones
- add component tests
- update translations
- add parseAPIError, a reusable function to
catch errors on the whole frontend app

Closes issue #293

♻️(frontend) improve general error catching

- change parseAPIError to make it reusable on all
requests
- update components depending on it
- remove link wrapping cancel button and
tabIndex=-1 to button
@daproclaima daproclaima merged commit c0cd136 into main Sep 26, 2024
14 checks passed
@daproclaima daproclaima deleted the feature/group-creation-error branch September 26, 2024 15:21
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.

Nom de groupe déjà existant : modifier le message d'erreur
2 participants