You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The content you are editing has changed. Please copy your edits and refresh the page.
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 :
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 ofreact-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
The text was updated successfully, but these errors were encountered: