Skip to content
TypeScript Shell
Branch: master
Clone or download
Latest commit f683a9c Nov 21, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore add gitignore Dec 1, 2016
.travis.yml Update tests Nov 20, 2019
LICENSE.md
README.md Update link Nov 21, 2019
fail.ts Port fail to deno Nov 20, 2019
mod.ts Add mod.ts Nov 20, 2019
test.sh
test.ts Port test to deno Nov 20, 2019

README.md

deno caught

This module lets you attach empty rejcetion handlers to promises to avoid errors when we want to handle rejections asynchronously.

It is a port of caught for Node, see: https://github.com/rsp/node-caught

More info

Doing something like this:

const p = Promise.reject(0);

setTimeout(() => p.catch(e => console.error('caught')), 0);

will result in the program terminating with an error:

error: Uncaught 0

This module lets you write:

const p = caught(Promise.reject(0));

setTimeout(() => p.catch(e => console.error('caught')), 0);

to avoid those errors on a per-promise basis.

Use at your own risk.

Background

For more info see this answer on Stack Overflow:

Usage

import { caught } from 'https://deno.land/x/caught/mod.ts';

const p = caught(Promise.reject(0));

Note that it is not the same as writing:

const p = Promise.reject(0).catch(() => {});

which would not return the original promise and wouldn't let you add catch handlers later.

Issues

For any bug reports or feature requests please post an issue on GitHub.

Author

Rafał Pocztarski
Follow on GitHub Follow on Twitter
Follow on Stack Exchange

Contributors

License

MIT License (Expat). See LICENSE.md for details.

You can’t perform that action at this time.