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

Consider changing the serverRequest function to throw #25

Open
karifrederiksen opened this issue Feb 24, 2022 · 2 comments
Open

Consider changing the serverRequest function to throw #25

karifrederiksen opened this issue Feb 24, 2022 · 2 comments
Labels
enhancement New feature or request frontend Affects the frontend

Comments

@karifrederiksen
Copy link
Collaborator

Currently the serverRequest function returns a union or either { isOk: true; data: ... } or { isOk: false; status: ...; genericErrors: ...; fieldErrors: ... }. I've noticed however that in many cases when isOk == false we often return an empty view, sometimes throw the error, and sometimes don't even check if there was an error. It seems this explicit approach to error handling is leading to bad practices, so I think we should change serverRequest to throw an error instead.

The error can then be caught and handled by a generic error boundary component which we wrap around arbitrary points in the application.

(also, I wonder, does react do anything when errors are thrown inside onClick handlers, or are they ignored?)

@karifrederiksen karifrederiksen added enhancement New feature or request frontend Affects the frontend question Further information is requested labels Feb 24, 2022
@karifrederiksen
Copy link
Collaborator Author

Turns out there are 27 references to this function. so it's a bit too much to change at once. I think I'll just introduce a second version of it that does throw when it encounters an error, and then we can gradually replace references to the current version with the new one.

There are probably also some cases where the current serverRequest is superior because it can't throw, so maybe we should keep both and just pick the appropriate one for each situation.

@karifrederiksen karifrederiksen removed the question Further information is requested label Feb 26, 2022
karifrederiksen added a commit that referenced this issue Mar 9, 2022
@LinusPhoenix
Copy link
Owner

Your current work on this will be included in 0.2.5, do you want me to keep this open or can this be closed?

LinusPhoenix added a commit that referenced this issue May 10, 2022
Improvements:
* #14: Improved the UX of the add raider dialog
* Made the title in the menu bar more stylish. Wow! Such style!
* #22: Disabled the chart animation on the raid team page.
* Added a WIP component to display on the raider page.

Bug Fixes:
* Fixed a bug where the raider overviews of characters with non-URI safe symbols in their name failed to generate.
* Fixed a bug where lockout data failed to parse for characters that cleared dungeons / raids in previous expansions, but not the current one.
* Fixed a bug where priests could fulfill the melee DPS role (sorry, you will have to be a paladin for that!)

Internal:
* Partial work on #25: Introduced a throwing version of serverRequest as well as error boundaries
* Create a global context for getting user information in the frontend
* #12: Upgraded frontend dependencies.
* #13: Enable eslint and fix warnings in the frontend.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request frontend Affects the frontend
Projects
None yet
Development

No branches or pull requests

2 participants