# @laborx/gulp-trycatch

> Provides gulp wrapper for intercepting errors in tasks

Latest version **0.1.1** (published 2019-02-22) · AGPL-3.0 license · 0 weekly downloads

## Install

```sh
npm install @laborx/gulp-trycatch
pnpm add @laborx/gulp-trycatch
yarn add @laborx/gulp-trycatch
bun add @laborx/gulp-trycatch
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2019-02-22 |
| First published | 2019-02-22 |
| Weekly downloads | 0 |
| License | AGPL-3.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 37.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | LaborX PTY |
| Maintainers | be1box, ozalexo, mike.chronobank, aliaksei.hiatsevich, alesanro |

## Links

- npm: https://www.npmjs.com/package/@laborx/gulp-trycatch
- Repository: git@gitlab.chronobank.io:SmartContracts/node-plugin-scripts
- npm.io page: https://npm.io/package/@laborx/gulp-trycatch

## Dependencies (1)

- [gulp](https://npm.io/package/gulp.md) ~4.0.0

## Recent versions

- 0.1.1 (latest) — 2019-02-22

## README

# Gulp try-catch-finally wrapper

Provides wrapper for handling errors inside `series` and `paralles` tasks by allowing to set `catchTask` and `finallyTask`.

## Usage

```typescript

import { tryCatchTaskWrapper } from "@laborx/gulp-trycatch";

export function failTask() {
	throws new Error("Cannot finish task in some cases")
}

export function cleanupTask() {
	// do some cleanup work that should be done it either way, for example, server port closing or file deletion
}

function observeOptionalErrorFunc(err: any) {
	console.error(`Found error during running task ${err}`)
}

// `sureTask` will always execute `cleanupTask` either `failTask` function throws or not
export const sureTask = tryCatchTaskWrapper(failTask, cleanupTask, observeOptionalErrorFunc, { silent: false })
```

You can pass optional configuration:

- `silent` - if `false` then an error will be propagated and rethrown and `sureTask` will eventually fail, if `true` then `sureTask` will succeed.

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