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

Improving error/exception handling #10732

Open
10 of 13 tasks
mlqn opened this issue Aug 1, 2023 · 1 comment
Open
10 of 13 tasks

Improving error/exception handling #10732

mlqn opened this issue Aug 1, 2023 · 1 comment
Labels
Epic Used by zenhub to identify the epics that group issues.

Comments

@mlqn
Copy link
Contributor

mlqn commented Aug 1, 2023

Asynchronous errors

We currently lack a consistent mechanism to catch expected and unexpected (e.g. a network problem/502/503/504 errors, 404 errors) asynchronous errors, resulting in the absence of error messages for the user.

I suggest implementing a global error handling system that catches and logs all errors coming from our API calls, displaying a specific message when possible, and a generic message otherwise. This generic message would say that an error has occurred, that we are aware of it, and that we are working on it. This approach could potentially reduce the number of messages we receive from users via the studio channels.

Since we are using Axios as our HTTP client, handling these errors can easily be done by using Axios interceptors. We could use these interceptors to perform other actions, such as logging out a user when we receive a 401 unauthorized exception, and informing them that their session has ended (#10718)

I suggest displaying these error messages as toast notifications using react-toastify. We could use it to display success messages and synchronous errors too. Using notifications have multiple benefits :

  • they are always visible, even if you are at the bottom of the page
  • they do not break the design by pushing blocks around
  • they can automatically disappear after a set amount of time
  • they're both non-blocking and non-intrusive, allowing users to continue their work interrupting them

To display specific messages, we could return an errorCode or a messageKey from the API, and then use this code/key to find the associated user-friendly message within our text resources in the right language.
This approach would help us to display distinct messages for the same HTTP error code (e.g. 400 error could be a missing parameter or a bad format, etc) and would also facilitate the implementation of specific actions on the client side. We probably cannot directly display the error message from the API, as it may contain technical information and is currently not translated into the local language.

In addition, we could still display some specific messages as we do today by using the onError callback of react-query and by checking the HTTP status code (e.g. 400 Bad Request) on the client side.

Synchronous / Rendering errors

To handle rendering errors, we could just use error boundaries as mentioned in this issue : #7265

Tasks

  1. mlqn
  2. mlqn
  3. kind/chore status/triage text/content ux
    JamalAlabdullah
  4. JamalAlabdullah framitdavid
    mlqn
  5. kind/bug
    JamalAlabdullah mlqn
  6. kind/feature-request quality/code
  7. 2 of 3
    area/contact kind/user-story ux
    mlqn
  8. kind/feature-request status/ready-for-specification
    framitdavid
  9. 0 of 2
    kind/chore status/triage
  10. kind/chore quality/code quality/testing status/triage
    mlqn
  11. area/designsystem area/notification good first issue kind/chore status/wontfix
  12. mlqn
@mlqn mlqn changed the title Error handling Improving error handling Aug 1, 2023
@mlqn mlqn changed the title Improving error handling Improving error/exception handling Aug 2, 2023
@RadhaRajagopalan RadhaRajagopalan added the Epic Used by zenhub to identify the epics that group issues. label Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Epic Used by zenhub to identify the epics that group issues.
Projects
Status: 📈 Todo
Development

No branches or pull requests

2 participants