Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

error

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

error

error handling utility

  • 0.0.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.1M
increased by4.32%
Maintainers
1
Weekly downloads
 
Created
Source

An error handling utility,

Blog posts

coming soon!

Examples

Documentation

Annotated source code coming soon.

error.throw(cb)

Returns a function which will throw the first parameter if it exists

error.throw(function (err, file) {
	// no error handling
	// error was thrown if exists
	// do things with file
});

error.passTo(errorHandler, cb)

Returns a function which will pass the error to the error handler if it exists and if not it will call the callback

error.passTo(next, function (err, data) {
	// no error handling.
	// error was passed to next if exists
	// handle data
});

error.thrower

A simple function that will throw the first argument if it exists

error.passTo(error.thrower, function (err, data) {
	// ...
});

error.whitelist

A whitelisting function. Pass it a filter and a cb and an optional error handler. If the filter returns true then invoke the cb, if it returns false invoke the error handler. If it returns neither don't do anything

error.whitelist(function (err) {
	if (err.isSpecial) {
		return true;
	} else {
		return false;
	}
}, function (err, data) {
	if (err.isSpecial) {
		handleIt();
	} else {
		handle(data);
	}
});

Keywords

FAQs

Package last updated on 17 Nov 2011

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc