Skip to content

Instantly share code, notes, and snippets.

@jmar777
Created September 22, 2016 16:16
Show Gist options
  • Select an option

  • Save jmar777/21ace6b8ea9b0cc428fc700faabb77e7 to your computer and use it in GitHub Desktop.

Select an option

Save jmar777/21ace6b8ea9b0cc428fc700faabb77e7 to your computer and use it in GitHub Desktop.

Revisions

  1. jmar777 created this gist Sep 22, 2016.
    13 changes: 13 additions & 0 deletions async-function-rejection.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    async function example() {
    // you can catch rejected promises that you await on
    try {
    await Promise.reject('blargh');
    } catch (err) {
    console.log(err);
    }

    // if you don't catch, then `example()` resolves to a rejected promise
    await Promise.reject('blah')
    }

    example().catch(err => console.error(err));