Skip to content
TypeScript Shell
Branch: master
Clone or download
Latest commit f683a9c Nov 21, 2019
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 Update link Nov 21, 2019
fail.ts Port fail to deno Nov 20, 2019
mod.ts Add mod.ts Nov 20, 2019
test.ts Port test to deno Nov 20, 2019

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:

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.


For more info see this answer on Stack Overflow:


import { caught } from '';

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.


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


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



MIT License (Expat). See for details.

You can’t perform that action at this time.