@onedaycat/ts-error
v2.0.5
Published
A library to create application error
Downloads
13
Readme
ts-error
A library to create application error, there are 8 definition type that including
- BAD_REQUEST
- NOT_FOUND
- TIMEOUT
- FORBIDDEN
- UNAUTHORIZED
- MAINTENANCE
- VALIDATION_ERROR
- INTERNAL_ERROR
Install
npm install @onedaycat/ts-error
Usage
import { def } from '@onedaycat/ts-error';
// define application error
const error = {
userNotFound: def.notFound('user_not_found', 'user not found');
productNotFound: def.notFound('product_not_found', 'product not found');
}
try {
// do stuff
} catch (e) {
// throw application error that defined instead
throw error.userNotFound.new().withCause(e);
}
Contributing
- Fork this repository.
- Create new branch with feature name in format
feature/FEATURE_NAME
- Run
npm install
oryarn
- Create your feature.
- Commit and set commit message with feature name.
- Push your code to your fork repository.
- Create pull request.