twilio / twilio-voice-react-native-app

Other
37 stars 21 forks source link

[VBLOCKS-1608] Serialize errors #77

Closed mhuynh5757 closed 1 year ago

mhuynh5757 commented 1 year ago

Submission Checklist

Description

This PR serializes errors using the miniSerializeError function provided by Redux Toolkit. Please note that user actions are not done in this PR, as there is further refactoring work needed as part of VBLOCKS-1834.

Breakdown

Validation

Additional Notes

Further work will be done to bring user actions up to the same standard.

Contributing to Twilio

All third-party contributors acknowledge that any contributions they provide will be made under the same open-source license that the open-source project is provided under.

mhuynh5757 commented 1 year ago

Non-serializable values such as error objects should not be put into actions and state as per the Redux team's guidelines. Right now, if an error occurs, the Redux Toolkit middlewares will extensively warn about the error object.

charliesantos commented 1 year ago

Non-serializable values such as error objects should not be put into actions and state as per the Redux team's guidelines. Right now, if an error occurs, the Redux Toolkit middlewares will extensively warn about the error object.

This is not obvious in the code. How do we make sure anyone modifying our code knows this and does not forget?

mhuynh5757 commented 1 year ago

It's a "Best Practice" according to the Redux docs, see here: https://redux.js.org/style-guide/#do-not-put-non-serializable-values-in-state-or-actions

Should we make a reference to these docs in our source code somewhere? Not sure what the best solution is.

charliesantos commented 1 year ago

It's a "Best Practice" according to the Redux docs, see here: https://redux.js.org/style-guide/#do-not-put-non-serializable-values-in-state-or-actions

Should we make a reference to these docs in our source code somewhere? Not sure what the best solution is.

A comment in the code that has a link to the best practice is better. Readme works too. Since you're doing this in multiple places in the code, is it possible to create a helper/util function that does this that way you can add that comment in a single location?