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

jas0ncn
Copy link
Contributor

@jas0ncn jas0ncn 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
Copy link

netlify bot commented May 6, 2019

Deploy preview for ant-design ready!

Built with commit db5da92

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

@codecov
Copy link

codecov bot 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
Copy link

codecov bot 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
Copy link
Contributor Author

jas0ncn 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
Copy link
Contributor Author

jas0ncn commented May 6, 2019

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

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

@afc163
Copy link
Member

afc163 commented May 8, 2019

来个 Test Case 如何?

@jas0ncn
Copy link
Contributor Author

jas0ncn commented May 8, 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
Copy link
Contributor Author

jas0ncn commented May 9, 2019

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

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

2 participants