@onedaycat/ts-error
TypeScript icon, indicating that this package has built-in type declarations

2.0.5 • Public • Published

npm (scoped) GitHub Coverage Status Build Status

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

  1. Fork this repository.
  2. Create new branch with feature name in format feature/FEATURE_NAME
  3. Run npm install or yarn
  4. Create your feature.
  5. Commit and set commit message with feature name.
  6. Push your code to your fork repository.
  7. Create pull request.

Dependencies (0)

    Dev Dependencies (9)

    Package Sidebar

    Install

    npm i @onedaycat/ts-error

    Weekly Downloads

    1

    Version

    2.0.5

    License

    MIT

    Unpacked Size

    17.3 kB

    Total Files

    15

    Last publish

    Collaborators

    • prapansak
    • witooh