# pull-catch

> Catch errors in a pull stream

Latest version **1.1.0** (published 2023-10-27) · ISC license · 0 weekly downloads

## Install

```sh
npm install pull-catch
pnpm add pull-catch
yarn add pull-catch
bun add pull-catch
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2023-10-27 |
| First published | 2016-11-26 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | nichoth |
| Maintainers | nichoth |
| Keywords | pull, stream, pull-stream, error, catch |

## Links

- npm: https://www.npmjs.com/package/pull-catch
- Repository: https://github.com/nichoth/pull-catch
- Homepage: https://github.com/nichoth/pull-catch#readme
- Issues: https://github.com/nichoth/pull-catch/issues
- npm.io page: https://npm.io/package/pull-catch

## Alternatives

- [@sentry/react-native](https://npm.io/package/@sentry/react-native.md) — 2.6M weekly downloads
- [@ardatan/aggregate-error](https://npm.io/package/@ardatan/aggregate-error.md) — 708.1K weekly downloads
- [custom-error-generator](https://npm.io/package/custom-error-generator.md) — 2.0K weekly downloads
- [@technik-sde/prosemirror-recreate-transform](https://npm.io/package/@technik-sde/prosemirror-recreate-transform.md) — 1.5K weekly downloads
- [@suchipi/error-utils](https://npm.io/package/@suchipi/error-utils.md) — 78 weekly downloads

## Recent versions

- 1.1.0 (latest) — 2023-10-27
- 1.0.1 — 2019-01-10
- 1.0.0 — 2016-12-20
- 0.0.2 — 2016-11-27
- 0.0.1 — 2016-11-27
- 0.0.0 — 2016-11-26

## README

# pull catch
Handle errors in pull streams

This is a through stream that can ensure your source stream always ends normally, even when it returns an error. This is useful if you are combining several source streams with pull-many, and you want to keep the remaining streams open even if one of them errors. 

## install 

    $ npm install pull-catch

## example

```js
var test = require('tape')
var S = require('pull-stream')
var Catch = require('../')

test('catch errors', function (t) {
    t.plan(2)
    S(
        S.error(new Error('test')),
        Catch(function onErr (err) {
            t.equal(err.message, 'test', 'should callback with error')
        }),
        S.collect(function (err, resp) {
            t.error(err, 'should end the stream without error')
        })
    )
})

test('return false to pass error', function (t) {
    t.plan(1)
    S(
        S.error(new Error('test')),
        Catch(function (err) {
            return false
        }),
        S.collect(function (err, res) {
            t.equal(err.message, 'test', 'should pass error in stream')
        })
    )
})

test('return truthy to emit one event then end', function (t) {
    t.plan(2)
    S(
        S.error(new Error('test')),
        Catch(function (err) {
            return 'test data'
        }),
        S.collect(function (err, res) {
            t.error(err, 'should not end with error')
            t.deepEqual(res, ['test data'], 'should emit one event')
        })
    )
})

test('callback is optional', function (t) {
    t.plan(1)
    S(
        S.error(new Error('test')),
        Catch(),
        S.collect(function (err, res) {
            t.error(err, 'should end stream without error')
        })
    )
})
```

---
_Source: https://npm.io/package/pull-catch · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
