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: Print reject error when ActionButton catch promise rejects #16437

Merged
merged 1 commit into from May 9, 2019

Conversation

Projects
None yet
2 participants
@jas0ncn
Copy link
Contributor

commented May 6, 2019

🤔 This is a ...

  • New feature
  • Bug fix
  • Site / document update
  • Component style update
  • TypeScript definition update
  • Refactoring
  • Code style optimization
  • Test Case
  • Branch merge
  • Other (about what?)

👻 What's the background?

There is nothing output on browser console when an error occurs while <Modal> components call onOk callback function.

💡 Solution

Emit error manually by add console.error(e)

📝 Changelog

  • English Changelog:
    • Print reject error when ActionButton catch promise rejects
    • Print reject error when Modal's onOk callback retures an promise rejects
  • Chinese Changelog (optional):
    • ActionButton 捕获到 Promise 的 Reject 的时候,打印错误。
    • Modal 组件 onOk 回调返回的 Promise 被 Reject 的时候,打印错误。

☑️ Self Check before Merge

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed
@netlify

This comment has been minimized.

Copy link

commented May 6, 2019

Deploy preview for ant-design ready!

Built with commit db5da92

https://deploy-preview-16437--ant-design.netlify.com

@codecov

This comment has been minimized.

Copy link

commented May 6, 2019

Codecov Report

Merging #16437 into master will decrease coverage by 0.01%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #16437      +/-   ##
==========================================
- Coverage   95.71%   95.69%   -0.02%     
==========================================
  Files         257      257              
  Lines        7068     7069       +1     
  Branches     2002     1965      -37     
==========================================
  Hits         6765     6765              
- Misses        302      303       +1     
  Partials        1        1
Impacted Files Coverage Δ
components/modal/ActionButton.tsx 73.33% <0%> (-2.53%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6bcd4b4...ae1b9d7. Read the comment docs.

@codecov

This comment has been minimized.

Copy link

commented May 6, 2019

Codecov Report

Merging #16437 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #16437      +/-   ##
==========================================
+ Coverage   95.65%   95.68%   +0.02%     
==========================================
  Files         258      258              
  Lines        7107     7108       +1     
  Branches     1992     1968      -24     
==========================================
+ Hits         6798     6801       +3     
+ Misses        307      305       -2     
  Partials        2        2
Impacted Files Coverage Δ
components/modal/ActionButton.tsx 90% <100%> (+14.13%) ⬆️
components/back-top/index.tsx 88.88% <0%> (-3.18%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 34d8ff8...db5da92. Read the comment docs.

@jas0ncn

This comment has been minimized.

Copy link
Contributor Author

commented May 6, 2019

具体场景主要是 Modal.comfirm 组件的 onOk 回调,如果是 Promise,会等到 Promise resolve 的时候关闭 Modal,但是如果此时 Promise 出错 reject,Modal 不会被关闭,且错误直接被吞掉了,无法定位问题,所以在 ActionButton 的 reject 回调中加一个 console.error 打印错误。

Demo 地址:https://codesandbox.io/s/zl0mj67yp4

@jas0ncn

This comment has been minimized.

Copy link
Contributor Author

commented May 6, 2019

所有使用 ActionButton 的 Modal 组件都会有这个问题:

  • Modal.info
  • Modal.success
  • Modal.error
  • Modal.warning
  • Modal.confirm
@afc163

This comment has been minimized.

Copy link
Member

commented May 8, 2019

来个 Test Case 如何?

@jas0ncn

This comment has been minimized.

Copy link
Contributor Author

commented May 8, 2019

好的👌明天补上

@jas0ncn jas0ncn force-pushed the jas0ncn:master branch from ae1b9d7 to db5da92 May 9, 2019

@jas0ncn jas0ncn changed the title Fix: Print reject error when ActionButton catch promise rejects fix: Print reject error when ActionButton catch promise rejects May 9, 2019

@jas0ncn

This comment has been minimized.

Copy link
Contributor Author

commented May 9, 2019

@afc163 已经补上测试用例,麻烦帮忙 review 一下哈

@afc163 afc163 merged commit 73a5b47 into ant-design:master May 9, 2019

28 of 30 checks passed

Header rules No header rules processed
Details
Pages changed 213 new files uploaded
Details
Codacy/PR Quality Review Up to standards. A positive pull request.
Details
CodeFactor No issues found.
Details
DEP All dependencies are resolved
LGTM analysis: JavaScript No new or fixed alerts
Details
Mixed content No mixed content detected
Details
Redirect rules 18 redirect rules processed
Details
Semantic Pull Request ready to be squashed
Details
WIP Ready for review
Details
ant-design.ant-design #ant design succeeded
Details
buildsize No change
Details
ci/circleci: compile Your tests passed on CircleCI!
Details
ci/circleci: dist Your tests passed on CircleCI!
Details
ci/circleci: lint Your tests passed on CircleCI!
Details
ci/circleci: setup Your tests passed on CircleCI!
Details
ci/circleci: test_dist Your tests passed on CircleCI!
Details
ci/circleci: test_dist_15 Your tests passed on CircleCI!
Details
ci/circleci: test_dom Your tests passed on CircleCI!
Details
ci/circleci: test_dom_15 Your tests passed on CircleCI!
Details
ci/circleci: test_es Your tests passed on CircleCI!
Details
ci/circleci: test_es_15 Your tests passed on CircleCI!
Details
ci/circleci: test_lib Your tests passed on CircleCI!
Details
ci/circleci: test_lib_15 Your tests passed on CircleCI!
Details
ci/circleci: test_node Your tests passed on CircleCI!
Details
ci/circleci: test_node_15 Your tests passed on CircleCI!
Details
codecov/patch 100% of diff hit (target 95.65%)
Details
codecov/project 95.68% (+0.02%) compared to 34d8ff8
Details
deploy/netlify Deploy preview ready!
Details
security/snyk - package.json (paranoidjk) No manifest changes detected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.