pixiebrix-extension
pixiebrix-extension copied to clipboard
Review error handling in RTK
- From https://github.com/reduxjs/redux-toolkit/issues/2392#issuecomment-1149732051
We never followed up on this suggestion by RTK authors:
you should probably handle those errors and use
rejectWithValue, or your well-known errors will get mixed up with unpredictable stuff.
Any improvement possible here? Feel free to close otherwise
Related
- #3613
- https://github.com/pixiebrix/pixiebrix-extension/issues/3372
- https://github.com/pixiebrix/pixiebrix-extension/pull/4112#discussion_r953792787
We can also review the appBaseQuery and the way we get error messages.
- A new Axios instance is created for every request. This is not optimal.
- Axios throws a rich error object, which we have to serialize any way to store in Redux losing all the benefits of that
AxiosError. We possibly could switch to RTKfetchBaseQuerywhich is meant to work with Redux and eliminate the need for serialization entirely. This may involve the way we get error messages (see p.3). -
Getting the error message doesn't have to rely on
isAxiosErrormethod. If an error has aresponseproperty, we can treat it as an API error.
- The logic for server errors is not as simple as you'd expect https://github.com/pixiebrix/pixiebrix-extension/blob/3c62042ebd5af6d5d415915e89724352e9072fb5/src/errors/networkErrorHelpers.ts#L176
This issue will be closed in 7 days unless the stale label is removed, or a comment is added to the issue.
This issue was closed because it has been stale for 7 days with no activity.