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

修复UnhandledPromiseRejection #72

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

修复UnhandledPromiseRejection #72

wants to merge 1 commit into from

Conversation

miacro
Copy link

@miacro miacro commented Dec 18, 2018

在Promise中同时调用handleResult和originCallback, 调用方需要同时处理两个地方的异常,可能导致UnhandledPromiseRejection, eg:
getBrandWCPayRequestParams:
需要处理来自unifiedOrder的两个错误(callback and rejected promise), 只处理了callback
UnhandledPromiseRejection
unifiedOrder:
只需要处理callback中的error
_signedQuery:
需要处理来自validate的两个错误(callback and rejected promise), 只处理了callback
UnhandledPromiseRejection
validate:
抛出错误
(总共有两个UnhandledPromiseRejection)

…unctions

* handleResult(err, result) and originCallback(err, result) will result
in UnhandledPromiseRejection. eg:

  getBrandWCPayRequestParams: two errors from unifiedOrder,
                              one in callback, handled,
                              another is the rejected promise, not catched,
                              UnhandledPromiseRejection
    unifiedOrder: error handled in callback ↑
      _signedQuery: two errors from validate, ↑
                    one in callback, handled,
                    another is the rejected promise, not catched,
                    UnhandledPromiseRejection
         validate: throw ProtocolError ↑

  Two UnhandledPromiseRejection in the example above,
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.

1 participant