Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
plugin-error
Advanced tools
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.
var PluginError = require('plugin-error');
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 });
new PluginError(pluginName, message[, options])
Error constructor that takes:
pluginName
- a String
that should be the module name of your pluginmessage
- a String
message or an existing Error
objectoptions
- an Object
of your optionsBehavior:
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.MIT
FAQs
Error handling for Vinyl plugins.
The npm package plugin-error receives a total of 774,605 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.