npm

customized-errors

1.0.2 • Public • Published

app-error

custom app error

install

# npm 
npm install customized-errors
 
# yarn 
yarn add customized-errors

Test

npm test
 
# or with yarn  
yarn run test

usage

const {TooManyRequestsError} = require('./error')
 
try {
    throw new TooManyRequestsError({message: 'You have exceeded your API rate limit', type: 'E_EXCEEDED_API_RATE_LIMIT', details:{limitCounts: 100, currentRequestCounts: 101}})
} catch (error) {
    console.error(error.message)
    console.log()
    console.error(error)
}
 
// prints:
 
// You have exceeded your API rate limit
 
// { name: 'TooManyRequestsError',
//   code: 'E4429',
//   type: 'E_EXCEEDED_API_RATE_LIMIT',
//   details: { limitCounts: 100, currentRequestCounts: 101 },
//   message: 'You have exceeded your API rate limit',
//   statusCode: 429 }

TODO

  1. add test
  2. update readme
  3. ...

Dependencies

  1. statuses

Package Sidebar

Install

npm i customized-errors

Weekly Downloads

1

Version

1.0.2

License

MIT

Unpacked Size

6.23 kB

Total Files

7

Last publish

Collaborators

  • chuidylan