# ch-error

> 一些常用的错误类型封装

Latest version **1.0.1** (published 2019-12-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install ch-error
pnpm add ch-error
yarn add ch-error
bun add ch-error
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-12-24 |
| First published | 2019-11-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | chengshubei |
| Maintainers | chengshubei |
| Keywords | chengshubei |

## Links

- npm: https://www.npmjs.com/package/ch-error
- Repository: https://github.com/chengshubei/ch-error
- Homepage: https://github.com/chengshubei/ch-error#readme
- Issues: https://github.com/chengshubei/ch-error/issues
- npm.io page: https://npm.io/package/ch-error

## Recent versions

- 1.0.1 (latest) — 2019-12-24
- 1.0.0 — 2019-11-22

## README

# ch-error

一些常用的错误类型和状态码封装, 适用于ch-koa等场景。

## Installation

```
$ npm install ch-error
```


## Example

Always pretty by default:

```js
const {AppError} = require('ch-error');
throw new AppError(12004, '订单已超时', 'none order', {orderId: 'xxxxxxxxx'});
```

## 结构
```
{
    code: 500,                  //状态码
    name: 'SystemError',        //错误名称
    message: '服务器内部错误',   //错误提示
    error: 'slie is not a function',   //具体错误
    data: {id: 333}             //返回数据 
}
```

### 错误类型和状态码

    ValidateError: '验证不通过(400)'
    ForbiddenError: '无权限访问(403)'
    NotFoundError: '请求资源未找到(404)'
    SystemError: '服务器内部错误(500)'
    UnavailableError: '服务未开放(501)'
    MaintainError: '系统维护中(503)'
    AppError: '自定义错误(>= 1000)'


# License

  MIT

---
_Source: https://npm.io/package/ch-error · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
