You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. # plugin-error
  7. [![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]
  8. Error handling for Vinyl plugins.
  9. ## Usage
  10. ```js
  11. var PluginError = require('plugin-error');
  12. var err = new PluginError('test', {
  13. message: 'something broke'
  14. });
  15. var err = new PluginError({
  16. plugin: 'test',
  17. message: 'something broke'
  18. });
  19. var err = new PluginError('test', 'something broke');
  20. var err = new PluginError('test', 'something broke', { showStack: true });
  21. var existingError = new Error('OMG');
  22. var err = new PluginError('test', existingError, { showStack: true });
  23. ```
  24. ## API
  25. ### `new PluginError(pluginName, message[, options])`
  26. Error constructor that takes:
  27. * `pluginName` - a `String` that should be the module name of your plugin
  28. * `message` - a `String` message or an existing `Error` object
  29. * `options` - an `Object` of your options
  30. **Behavior:**
  31. * By default the stack will not be shown. Set `options.showStack` to true if you think the stack is important for your error.
  32. * If you pass an error object as the message the stack will be pulled from that, otherwise one will be created.
  33. * If you pass in a custom stack string you need to include the message along with that.
  34. * Error properties will be included in `err.toString()`, but may be omitted by including `{ showProperties: false }` in the options.
  35. ## License
  36. MIT
  37. [downloads-image]: http://img.shields.io/npm/dm/plugin-error.svg
  38. [npm-url]: https://www.npmjs.com/package/plugin-error
  39. [npm-image]: http://img.shields.io/npm/v/plugin-error.svg
  40. [travis-url]: https://travis-ci.org/gulpjs/plugin-error
  41. [travis-image]: http://img.shields.io/travis/gulpjs/plugin-error.svg?label=travis-ci
  42. [appveyor-url]: https://ci.appveyor.com/project/gulpjs/plugin-error
  43. [appveyor-image]: https://img.shields.io/appveyor/ci/gulpjs/plugin-error.svg?label=appveyor
  44. [coveralls-url]: https://coveralls.io/r/gulpjs/plugin-error
  45. [coveralls-image]: http://img.shields.io/coveralls/gulpjs/plugin-error/master.svg
  46. [gitter-url]: https://gitter.im/gulpjs/gulp
  47. [gitter-image]: https://badges.gitter.im/gulpjs/gulp.svg