def-err

0.1.1 • Public • Published

Define Custom Error

only support es6

Usage

const defErr = require('def-err');

const BusinessError = defErr('BusinessError', '发生业务错误了', ['code', 'message']);
const HttpError = defErr('HttpError', '发生了Http错误', ['status', 'response']);

new BusinessError('miss_arguments', '参数缺失了,请检查是否缺少XX参数');
new HttpError('404', '找不到资源');

Readme

Keywords

Package Sidebar

Install

npm i def-err

Weekly Downloads

2

Version

0.1.1

License

ISC

Last publish

Collaborators

  • zhangmhao