JSPM

@adorade/plugin-error

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2942
  • Score
    100M100P100Q124788F
  • License MIT

Error handling for Gulp plugins with ESM support

Package Exports

  • @adorade/plugin-error
  • @adorade/plugin-error/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@adorade/plugin-error) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Plugin Error

NPM version GitHub package.json version license Depfu Status GitHub Actions Renovate enabled

Error handling for Gulp plugins with ESM support.

This package is pure ESM. Please read this.

Installation

npm install @adorade/plugin-error --save-dev
# Or with yarn:
yarn add @adorade/plugin-error --dev

Usage

import PluginError from '@adorade/plugin-error';

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

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

const err = new PluginError('test', 'something broke');

const err = new PluginError('test', 'something broke', {
    showStack: true,      // false (default) | true
    showProperties: false // true (default) | false
});

const existingError = new Error('OMG');
const err = new PluginError('test', existingError, { showStack: true });

API

new PluginError(plugin, message[, options])

Error constructor that takes:

  • plugin - 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

See the MIT LICENSE file for license rights and limitations.