Skip to content

Commit

Permalink
Docs: Add rejection tracking to README
Browse files Browse the repository at this point in the history
  • Loading branch information
nzakas committed Jan 7, 2021
1 parent 3a6b2b7 commit 98ae59d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,25 @@ const fulfilled = Pledge.resolve(42);
const rejected = Pledge.reject(new Error("Uh oh!"));
```

To watch for unhandled rejections:

```js
// this function is called when any pledge is rejected without a handler
// similar to window.onunhandledrejection
Pledge.onUnhandledRejection = event => {
const { pledge, reason } = event;

// cancel warning about this unhandled rejection
event.preventDefault();
};

// this function is called when a previously unhandled rejection becomes handled
// similar to window.onrejectionhandled;
Pledge.onRejectionHandled = event => {
const { pledge, reason } = event;
};
```

## Frequently Asked Questions (FAQ)

### Why make this package?
Expand Down

0 comments on commit 98ae59d

Please sign in to comment.