tiny-code-error
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

tiny-code-error

License: MIT

It is very-very-very simple Error class, which have code and payload. I create this package, because I used this class in many-many projects, because Code Error it is more informative and type control then simple Error with just message.

📦 Install

yarn add tiny-code-error
pnpm i tiny-code-error

🌟 Example

export enum PaymentErrorCode {
  USER_NOT_REGISTER = "app/payment/user-not-register",
  PAYMENT_NOT_VERIFY = "app/payment/not-verify",
  NOT_NEW = "app/payment/not-new",
  CANT_UPDATE = "app/payment/cant-update",
  ALREADY_PAID = "app/payment/already-paid",
  VALIDATION_ERROR = "app/payment/validation-error",
  SUBSCRIPTION_PAYMENT_INCCORECT = "app/payment/subscription-payment-incorrect",
}

export class PaymentError extends CodeError<PaymentErrorCode> {}

export const enum ResetPasswordErrorCode {
  USER_NOT_FOUND = "app/reset/user-not-found",
  UNKNOWN = "app/reset/unknown",
}

export class ResetPasswordError extends CodeError<ResetPasswordErrorCode> {}

Readme

Keywords

Package Sidebar

Install

npm i tiny-code-error

Weekly Downloads

81

Version

0.1.2

License

MIT

Unpacked Size

7.05 kB

Total Files

8

Last publish

Collaborators

  • adinvadim