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

fix(xo-web/editable/number): throw error if onChange fails #5634

Merged
merged 3 commits into from Mar 3, 2021

Conversation

MathieuRA
Copy link
Member

@MathieuRA MathieuRA commented Mar 2, 2021

Check list

Check if done, if not relevant leave unchecked.

  • PR reference the relevant issue (e.g. Fixes #007 or See xoa-support#42)
  • if UI changes, a screenshot has been added to the PR
  • documentation updated
  • CHANGELOG.unreleased.md:
    • enhancement/bug fix entry added
    • list of packages to release updated (${name} v${new version})
  • I have tested added/updated features (and impacted code)

Process

  1. create a PR as soon as possible
  2. mark it as WiP: (Work in Progress) if not ready to be merged
  3. when you want a review, add a reviewer (and only one)
  4. if necessary, update your PR, and re- add a reviewer

From the Four Agreements:

  1. Be impeccable with your word.
  2. Don't take anything personally.
  3. Don't make assumptions.
  4. Always do your best.

@MathieuRA MathieuRA requested a review from badrAZ March 2, 2021 08:44

this.props.onChange(value, params)
await this.props.onChange(value, params)
} catch (error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code above the onChange cannot throw an error.

@badrAZ badrAZ requested a review from pdonias March 2, 2021 10:58
Comment on lines 310 to 311
} catch (error) {
throw error
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the point of catching an error just to rethrow it.

Copy link
Member

@julien-f julien-f Mar 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, the important change appears to be the await.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the point of catching an error just to rethrow it.

The current behaviour is: if we edit a number and it's failing, the UI are not displaying an error, and for the user it's look like it worked.
Eg: If you try to edit a rate limit network as viewer, the modification will fail, and a success tooltip will appear next to the input

By throwing an error in the case of failure, the error tooltip is displayed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MathieuRA Your comment does not explain why the try/catch is necessary.

Because what you're doing right now is catch an exception and then rethrow it, which is the same as not catching it in the first place.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ho okay, i understand.

So only the await is necessary

@MathieuRA MathieuRA requested a review from badrAZ March 3, 2021 09:44
@badrAZ badrAZ requested a review from pdonias March 3, 2021 12:45
@pdonias pdonias changed the title fix(xo-web/number): throw error if onChange are failing fix(xo-web/editable/number): throw error if onChange fails Mar 3, 2021
@pdonias pdonias merged commit f2d4fdd into master Mar 3, 2021
@pdonias pdonias deleted the mathieu-fixErrorEditableNumber branch March 3, 2021 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants