https://github.com/gulpjs/plugin-error
Error handling for vinyl plugins. Just an abstraction of what's in gulp-util with minor reformatting.
https://github.com/gulpjs/plugin-error
Last synced: 8 months ago
JSON representation
Error handling for vinyl plugins. Just an abstraction of what's in gulp-util with minor reformatting.
- Host: GitHub
- URL: https://github.com/gulpjs/plugin-error
- Owner: gulpjs
- License: mit
- Created: 2015-04-26T20:43:07.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2022-12-06T19:28:42.000Z (over 3 years ago)
- Last Synced: 2025-08-03T05:30:46.746Z (11 months ago)
- Language: JavaScript
- Size: 41 KB
- Stars: 19
- Watchers: 8
- Forks: 13
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# plugin-error
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][ci-image]][ci-url] [![Coveralls Status][coveralls-image]][coveralls-url]
Error handling for Vinyl plugins.
## Usage
```js
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 });
```
## API
### `new PluginError(pluginName, message[, options])`
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
**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.
## License
MIT
[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]: https://img.shields.io/npm/v/plugin-error.svg?style=flat-square
[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
[coveralls-url]: https://coveralls.io/r/gulpjs/plugin-error
[coveralls-image]: https://img.shields.io/coveralls/gulpjs/plugin-error/master.svg?style=flat-square