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

plugin-error

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

plugin-error - npm Package Compare versions

Comparing version 1.0.1 to 2.0.0

20

index.d.ts

@@ -8,3 +8,7 @@ declare namespace PluginError {

*/
new <E extends Error>(plugin: string, error: E, options?: Options): PluginError<E>;
new <E extends Error>(
plugin: string,
error: E,
options?: Options
): PluginError<E>;

@@ -16,3 +20,7 @@ /**

*/
new <E extends Error = Error>(plugin: string, error: E | string, options: Options): PluginError<E | {[K in keyof E]: undefined}>;
new <E extends Error = Error>(
plugin: string,
error: E | string,
options: Options
): PluginError<E | { [K in keyof E]: undefined }>;

@@ -23,3 +31,6 @@ /**

*/
new <E extends Error = Error>(plugin: string, error: E | string | (Options & {message: string})): PluginError<E | {[K in keyof E]: undefined}>;
new <E extends Error = Error>(
plugin: string,
error: E | string | (Options & { message: string })
): PluginError<E | { [K in keyof E]: undefined }>;

@@ -29,3 +40,3 @@ /**

*/
new(options: Options & {plugin: string, message: string}): PluginError;
new (options: Options & { plugin: string; message: string }): PluginError;
}

@@ -49,3 +60,2 @@

/**

@@ -52,0 +62,0 @@ * Line number where the error occurred

var util = require('util');
var colors = require('ansi-colors');
var extend = require('extend-shallow');
var differ = require('arr-diff');
var union = require('arr-union');
var nonEnum = ['message', 'name', 'stack'];
var ignored = union(nonEnum, ['__safety', '_stack', 'plugin', 'showProperties', 'showStack']);
var props = ['fileName', 'lineNumber', 'message', 'name', 'plugin', 'showProperties', 'showStack', 'stack'];
var ignored = new Set(
nonEnum.concat([
'__safety',
'_stack',
'plugin',
'showProperties',
'showStack',
'domain',
'domainThrown',
])
);
var props = [
'fileName',
'lineNumber',
'message',
'name',
'plugin',
'showProperties',
'showStack',
'stack',
];
function PluginError(plugin, message, options) {
if (!(this instanceof PluginError)) {
throw new Error('Call PluginError using new');
return new PluginError(plugin, message, options);
}

@@ -22,6 +38,6 @@

if (typeof opts.error === 'object') {
var keys = union(Object.keys(opts.error), nonEnum);
var keys = new Set(Object.keys(opts.error).concat(nonEnum));
// These properties are not enumerable, so we have to add them explicitly.
keys.forEach(function(prop) {
keys.forEach(function (prop) {
self[prop] = opts.error[prop];

@@ -32,3 +48,3 @@ });

// Opts object can override
props.forEach(function(prop) {
props.forEach(function (prop) {
if (prop in opts) {

@@ -40,7 +56,3 @@ this[prop] = opts[prop];

// Defaults
if (!this.name) {
this.name = 'Error';
}
if (!this.stack) {
/**

@@ -56,3 +68,3 @@ * `Error.captureStackTrace` appends a stack property which

var safety = {};
safety.toString = function() {
safety.toString = function () {
return this._messageWithDetails() + '\nStack:';

@@ -78,3 +90,3 @@ }.bind(this);

PluginError.prototype._messageWithDetails = function() {
PluginError.prototype._messageWithDetails = function () {
var msg = 'Message:\n ' + this.message;

@@ -92,3 +104,3 @@ var details = this._messageDetails();

PluginError.prototype._messageDetails = function() {
PluginError.prototype._messageDetails = function () {
if (!this.showProperties) {

@@ -98,3 +110,5 @@ return '';

var props = differ(Object.keys(this), ignored);
var props = Object.keys(this).filter(function (key) {
return !ignored.has(key);
});
var len = props.length;

@@ -121,4 +135,4 @@

PluginError.prototype.toString = function() {
var detailsWithStack = function(stack) {
PluginError.prototype.toString = function () {
var detailsWithStack = function (stack) {
return this._messageWithDetails() + '\nStack:\n' + stack;

@@ -132,6 +146,4 @@ }.bind(this);

msg = this.__safety.stack;
} else if (this._stack) {
msg = detailsWithStack(this._stack);
} else {

@@ -166,9 +178,8 @@ // Stack from wrapped error

}
opts = opts || {};
if (message instanceof Error) {
opts.error = message;
opts = Object.assign({}, opts, { error: message });
} else if (typeof message === 'object') {
opts = message;
opts = Object.assign({}, message);
} else {
opts.message = message;
opts = Object.assign({}, opts, { message: message });
}

@@ -190,6 +201,9 @@ opts.plugin = plugin;

function defaults(opts) {
return extend({
showStack: false,
showProperties: true,
}, opts);
return Object.assign(
{
showStack: false,
showProperties: true,
},
opts
);
}

@@ -196,0 +210,0 @@

{
"name": "plugin-error",
"version": "1.0.1",
"version": "2.0.0",
"description": "Error handling for Vinyl plugins.",
"author": "Gulp Team <team@gulpjs.com> (http://gulpjs.com/)",
"author": "Gulp Team <team@gulpjs.com> (https://gulpjs.com/)",
"contributors": [

@@ -13,3 +13,3 @@ "Jon Schlinkert <jon.schlinkert@sellside.com>",

"engines": {
"node": ">= 0.10"
"node": ">=10.13.0"
},

@@ -23,26 +23,28 @@ "main": "index.js",

"scripts": {
"lint": "eslint . && jscs index.js test/",
"lint": "eslint .",
"pretest": "npm run lint",
"test": "mocha --async-only && npm run test-types",
"test-types": "tsc -p test/types",
"cover": "istanbul cover _mocha --report lcovonly",
"coveralls": "npm run cover && istanbul-coveralls"
"test": "nyc mocha --async-only",
"test-types": "tsc -p test/types"
},
"dependencies": {
"ansi-colors": "^1.0.1",
"arr-diff": "^4.0.0",
"arr-union": "^3.1.0",
"extend-shallow": "^3.0.2"
"ansi-colors": "^1.0.1"
},
"devDependencies": {
"eslint": "^1.7.3",
"eslint-config-gulp": "^2.0.0",
"expect": "^1.20.2",
"istanbul": "^0.4.3",
"istanbul-coveralls": "^1.0.3",
"jscs": "^2.3.5",
"jscs-preset-gulp": "^1.0.0",
"mocha": "^3.0.0",
"typescript": "^2.6.2"
"eslint": "^7.0.0",
"eslint-config-gulp": "^5.0.0",
"eslint-plugin-node": "^11.1.0",
"expect": "^27.0.0",
"mocha": "^8.0.0",
"nyc": "^15.0.0",
"typescript": "^4.7.4"
},
"nyc": {
"reporter": [
"lcov",
"text-summary"
]
},
"prettier": {
"singleQuote": true
},
"keywords": [

@@ -49,0 +51,0 @@ "error",

@@ -9,3 +9,3 @@ <p align="center">

[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![AppVeyor Build Status][appveyor-image]][appveyor-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Gitter chat][gitter-image]][gitter-url]
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][ci-image]][ci-url] [![Coveralls Status][coveralls-image]][coveralls-url]

@@ -20,3 +20,3 @@ Error handling for Vinyl plugins.

var err = new PluginError('test', {
message: 'something broke'
message: 'something broke',
});

@@ -26,3 +26,3 @@

plugin: 'test',
message: 'something broke'
message: 'something broke',
});

@@ -43,12 +43,13 @@

Error constructor that takes:
* `pluginName` - a `String` that should be the module name of your plugin
* `message` - a `String` message or an existing `Error` object
* `options` - an `Object` of your options
- `pluginName` - a `String` that should be the module name of your plugin
- `message` - a `String` message or an existing `Error` object
- `options` - an `Object` of your options
**Behavior:**
* By default the stack will not be shown. Set `options.showStack` to true if you think the stack is important for your error.
* If you pass an error object as the message the stack will be pulled from that, otherwise one will be created.
* If you pass in a custom stack string you need to include the message along with that.
* Error properties will be included in `err.toString()`, but may be omitted by including `{ showProperties: false }` in the options.
- By default the stack will not be shown. Set `options.showStack` to true if you think the stack is important for your error.
- If you pass an error object as the message the stack will be pulled from that, otherwise one will be created.
- If you pass in a custom stack string you need to include the message along with that.
- Error properties will be included in `err.toString()`, but may be omitted by including `{ showProperties: false }` in the options.

@@ -59,16 +60,12 @@ ## License

[downloads-image]: http://img.shields.io/npm/dm/plugin-error.svg
<!-- prettier-ignore-start -->
[downloads-image]: https://img.shields.io/npm/dm/plugin-error.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/plugin-error
[npm-image]: http://img.shields.io/npm/v/plugin-error.svg
[npm-image]: https://img.shields.io/npm/v/plugin-error.svg?style=flat-square
[travis-url]: https://travis-ci.org/gulpjs/plugin-error
[travis-image]: http://img.shields.io/travis/gulpjs/plugin-error.svg?label=travis-ci
[ci-url]: https://github.com/gulpjs/plugin-error/actions?query=workflow:dev
[ci-image]: https://img.shields.io/github/workflow/status/gulpjs/plugin-error/dev?style=flat-square
[appveyor-url]: https://ci.appveyor.com/project/gulpjs/plugin-error
[appveyor-image]: https://img.shields.io/appveyor/ci/gulpjs/plugin-error.svg?label=appveyor
[coveralls-url]: https://coveralls.io/r/gulpjs/plugin-error
[coveralls-image]: http://img.shields.io/coveralls/gulpjs/plugin-error/master.svg
[gitter-url]: https://gitter.im/gulpjs/gulp
[gitter-image]: https://badges.gitter.im/gulpjs/gulp.svg
[coveralls-image]: https://img.shields.io/coveralls/gulpjs/plugin-error/master.svg?style=flat-square
<!-- prettier-ignore-end -->

Sorry, the diff of this file is not supported yet

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