Skip to content

♻️ Use tryResolve instead of Promise.resolve with call#15143

Merged
jridgewell merged 4 commits intoampproject:masterfrom
jridgewell:promise-tryResolve
May 8, 2018
Merged

♻️ Use tryResolve instead of Promise.resolve with call#15143
jridgewell merged 4 commits intoampproject:masterfrom
jridgewell:promise-tryResolve

Conversation

@jridgewell
Copy link
Copy Markdown
Contributor

This moves all uses of Promise.resolve(FUNC()) to tryResolve(FUNC).

This both captures sync throwing errors, and resolves with the return value of the FUNC (which may be a async rejection promise). Either way, it allows handling of errors using a #catch block.

@jridgewell jridgewell requested review from aghassemi and rsimha May 8, 2018 00:00
@jridgewell jridgewell force-pushed the promise-tryResolve branch from 1c9a494 to 8caddec Compare May 8, 2018 00:05
@jridgewell jridgewell force-pushed the promise-tryResolve branch from 66c9ab6 to 18a9a27 Compare May 8, 2018 03:44
@jridgewell jridgewell merged commit ca101d0 into ampproject:master May 8, 2018
@jridgewell jridgewell deleted the promise-tryResolve branch May 8, 2018 04:24
noranazmy pushed a commit to noranazmy/amphtml that referenced this pull request May 10, 2018
)

* Move into utils/promise

* Move to using tryResolve

* Typecast

* Bump
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants