Created
January 10, 2026 20:59
-
-
Save jcoglan/3e27b5fe676d11f3040e8a50afbf3316 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict' | |
| function run (fn) { | |
| let { promise, resolve, reject } = Promise.withResolvers() | |
| let p = fn() | |
| p.then(resolve, reject) | |
| // p.finally(() => {}) // -- uncomment for a surprise | |
| return promise | |
| } | |
| async function main () { | |
| try { | |
| await run(() => Promise.reject(new Error('oh no'))) | |
| } catch (err) { | |
| console.log('failed') | |
| } | |
| } | |
| main().then( | |
| () => console.log('ok'), | |
| () => console.log('not ok') | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment