Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@laborx/gulp-trycatch

Package Overview
Dependencies
Maintainers
5
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@laborx/gulp-trycatch

Provides gulp wrapper for intercepting errors in tasks

latest
npmnpm
Version
0.1.1
Version published
Maintainers
5
Created
Source

Gulp try-catch-finally wrapper

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

Usage


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.

FAQs

Package last updated on 22 Feb 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts