@arrows/error

中文文档
1.0.2发布于 2019/10/17ISCCommonJS零依赖近 30 天下载 23.6万

Error helpers library

原始使用文档
文档目录6 节
  1. Table of contents
  2. Introduction
  3. Installation
  4. API reference
  5. createErrorClass
  6. License

@arrows/error

npm (scoped) CircleCI David (path) Codecov npm bundle size (scoped) GitHub

Table of contents

  1. Introduction
  2. Installation
  3. API reference
  4. License

Introduction

The library contains a set of helper functions for error handling.

The library has built-in type definitions, which provide an excellent IDE support.

Installation

Via NPM:

npm i @arrows/error

Via Yarn:

yarn add @arrows/error

API reference

createErrorClass

Creates custom error class that returns extended error object that can be serialized to JSON.

Parameters

  • name - The error name (should be the same as the name of the variable to which the class is assigned)
  • message - Error message
  • serializeStacktrace An optional boolean flag, to indicate weather a stacktrace should be serialized (default: false)

Returns

  • Returns custom error class that takes one optional argument - error details

Interface

(name , message, serializeStacktrace?) => custom_error_class

Examples

Create a custom error class:

const MyError = createErrorClass('MyError', 'some message')

Create a custom error class with serializable stacktrace:

const MyError = createErrorClass('MyError', 'some message', true)

License

Project is under open, non-restrictive ISC license.

版本与发布记录

@arrows/error 共发布 7 个版本,首次发布于 2019/09/17;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.2latest2019/10/177 年前
1.0.12019/10/147 年前
1.0.02019/10/147 年前
0.1.32019/09/227 年前
0.1.22019/09/227 年前
0.1.12019/09/217 年前

关于 @arrows/error 的常见问题

@arrows/error 是什么?

Error helpers library

如何安装 @arrows/error?

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

@arrows/error 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/arrows__error 是否存在。

@arrows/error 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@arrows/error 可以商用吗?

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

@arrows/error 的下载量有多少?

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

@arrows/error 还在维护吗?

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