Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/gavinning/assert

断言,失败信息支持携带err-code
https://github.com/gavinning/assert

assert err-code error-code verify

Last synced: about 2 months ago
JSON representation

断言,失败信息支持携带err-code

Awesome Lists containing this project

README

        

assert
---
断言,失败信息支持携带err-code

### Install
```sh
npm i @4a/assert
```

### Usage
```js
const assert = require('@4a/assert')

try {
assert.ok(0, 100, 'error code 100')
}
catch(err) {
console.log({
code: err.code,
message: err.message
})
}

try {
assert.fail(1, 200, 'error code 200')
}
catch(err) {
console.log({
code: err.code,
message: err.message
})
}
```