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 = try throw message: 'You have exceeded your API rate limit' type: 'E_EXCEEDED_API_RATE_LIMIT' details:limitCounts: 100 currentRequestCounts: 101 catch error console console console // 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
- add test
- update readme
- ...