pixiebrix-extension icon indicating copy to clipboard operation
pixiebrix-extension copied to clipboard

Review error handling in RTK

Open fregante opened this issue 3 years ago • 2 comments

  • 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

fregante avatar Aug 15 '22 07:08 fregante

We can also review the appBaseQuery and the way we get error messages.

  1. A new Axios instance is created for every request. This is not optimal.
  2. 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 RTK fetchBaseQuery which 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).
  3. Getting the error message doesn't have to rely on isAxiosError method. If an error has a response property, we can treat it as an API error.

BALEHOK avatar Aug 26 '22 09:08 BALEHOK

  1. 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

fregante avatar Aug 26 '22 09:08 fregante

This issue will be closed in 7 days unless the stale label is removed, or a comment is added to the issue.

github-actions[bot] avatar Jan 02 '24 00:01 github-actions[bot]

This issue was closed because it has been stale for 7 days with no activity.

github-actions[bot] avatar Jan 09 '24 00:01 github-actions[bot]