Security News
Combatting Alert Fatigue by Prioritizing Malicious Intent
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
plugin-error
Advanced tools
Error handling for vinyl plugins. Just an abstraction of what's in gulp-util with minor changes.
The plugin-error npm package is designed to simplify error handling in plugin development, particularly for Gulp plugins. It provides a consistent way to create and manage errors, making it easier to debug and handle errors in a standardized manner.
Creating a PluginError
This feature allows you to create a new PluginError instance. The first argument is the plugin name, and the second argument is the error message. This helps in identifying which plugin caused the error.
const PluginError = require('plugin-error');
const err = new PluginError('MyPlugin', 'Something went wrong!');
console.error(err.toString());
Handling Error Options
This feature allows you to pass an options object to the PluginError constructor. The options can include properties like 'message' and 'showStack' to customize the error output.
const PluginError = require('plugin-error');
const err = new PluginError('MyPlugin', {
message: 'Something went wrong!',
showStack: true
});
console.error(err.toString());
Using Error Codes
This feature allows you to specify an error code, which can be useful for programmatically identifying different types of errors.
const PluginError = require('plugin-error');
const err = new PluginError('MyPlugin', {
message: 'Something went wrong!',
code: 'EPLUGIN'
});
console.error(err.toString());
The fancy-log package is used for logging messages in a more readable format. While it doesn't specifically handle errors, it can be used alongside plugin-error to log error messages in a more user-friendly way.
The gulplog package is a logging utility specifically designed for Gulp. It provides a way to log messages at different levels (info, warn, error). While it doesn't create error objects like plugin-error, it can be used to log errors created by plugin-error.
The chalk package is used for styling terminal string output. It can be used in conjunction with plugin-error to colorize error messages, making them easier to read and debug.
Error handling for vinyl plugins. Just an abstraction of what's in gulp-util with minor changes.
npm i plugin-error --save
var PluginError = require('plugin-error');
Params
pluginName
should be the module name of your pluginmessage
{String|Object}: may be a string or an existing error objectoptions
{Object}Behavior:
options.showStack
to true if you think the stack is important for your error.err.toString()
, but may be omitted by including {showProperties: false}
in the options.Examples
All of the following are acceptable forms of instantiation:
var err = new PluginError('test', {
message: 'something broke'
});
var err = new PluginError({
plugin: 'test',
message: 'something broke'
});
var err = new PluginError('test', 'something broke');
var err = new PluginError('test', 'something broke', {showStack: true});
var existingError = new Error('OMG');
var err = new PluginError('test', existingError, {showStack: true});
Install dev dependencies:
npm i -d && npm test
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue
Jon Schlinkert
Copyright (c) 2015 Jon Schlinkert Released under the MIT license.
This file was generated by verb-cli on May 01, 2015.
FAQs
Error handling for Vinyl plugins.
The npm package plugin-error receives a total of 1,785,929 weekly downloads. As such, plugin-error popularity was classified as popular.
We found that plugin-error demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Security News
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.