UNPKG

2.23 kBMarkdownView Raw
1<p align="center">
2 <a href="http://gulpjs.com">
3 <img height="257" width="114" src="https://raw.githubusercontent.com/gulpjs/artwork/master/gulp-2x.png">
4 </a>
5</p>
6
7# plugin-error
8
9[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][ci-image]][ci-url] [![Coveralls Status][coveralls-image]][coveralls-url]
10
11Error handling for Vinyl plugins.
12
13## Usage
14
15```js
16var PluginError = require('plugin-error');
17
18var err = new PluginError('test', {
19 message: 'something broke',
20});
21
22var err = new PluginError({
23 plugin: 'test',
24 message: 'something broke',
25});
26
27var err = new PluginError('test', 'something broke');
28
29var err = new PluginError('test', 'something broke', { showStack: true });
30
31var existingError = new Error('OMG');
32var err = new PluginError('test', existingError, { showStack: true });
33```
34
35## API
36
37### `new PluginError(pluginName, message[, options])`
38
39Error constructor that takes:
40
41- `pluginName` - a `String` that should be the module name of your plugin
42- `message` - a `String` message or an existing `Error` object
43- `options` - an `Object` of your options
44
45**Behavior:**
46
47- By default the stack will not be shown. Set `options.showStack` to true if you think the stack is important for your error.
48- If you pass an error object as the message the stack will be pulled from that, otherwise one will be created.
49- If you pass in a custom stack string you need to include the message along with that.
50- Error properties will be included in `err.toString()`, but may be omitted by including `{ showProperties: false }` in the options.
51
52## License
53
54MIT
55
56<!-- prettier-ignore-start -->
57[downloads-image]: https://img.shields.io/npm/dm/plugin-error.svg?style=flat-square
58[npm-url]: https://www.npmjs.com/package/plugin-error
59[npm-image]: https://img.shields.io/npm/v/plugin-error.svg?style=flat-square
60
61[ci-url]: https://github.com/gulpjs/plugin-error/actions?query=workflow:dev
62[ci-image]: https://img.shields.io/github/workflow/status/gulpjs/plugin-error/dev?style=flat-square
63
64[coveralls-url]: https://coveralls.io/r/gulpjs/plugin-error
65[coveralls-image]: https://img.shields.io/coveralls/gulpjs/plugin-error/master.svg?style=flat-square
66<!-- prettier-ignore-end -->