@adorade/plugin-error

中文文档
2.0.1发布于 2024/09/30MITTypeScriptES Module近 30 天下载 1.4万

Error handling for Gulp plugins with ESM support

原始使用文档
文档目录4 节
  1. Installation
  2. Usage
  3. API
  4. License

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.

版本与发布记录

@adorade/plugin-error 共发布 3 个版本,首次发布于 2024/02/15;过去 12 个月发布了 0 个版本。

版本发布日期距今
2.0.1latest2024/09/302 年前
2.0.02024/09/302 年前
1.0.02024/02/152 年前

关于 @adorade/plugin-error 的常见问题

@adorade/plugin-error 是什么?

Error handling for Gulp plugins with ESM support

如何安装 @adorade/plugin-error?

在项目目录运行 npm install @adorade/plugin-error,或使用 pnpm add / yarn add / bun add。

@adorade/plugin-error 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@adorade/plugin-error 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@adorade/plugin-error 可以商用吗?

@adorade/plugin-error 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@adorade/plugin-error 的下载量有多少?

根据 npm 官方下载统计,@adorade/plugin-error 在 2026/10/05 – 2026/11/03 这 30 天内被下载 14,221 次,日均约 474 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@adorade/plugin-error 还在维护吗?

最新版本 2.0.1 发布于 2024/09/30(2 年前);至今共发布 3 个版本,其中过去 12 个月发布了 0 个;首次发布于 2024/02/15。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。