https://github.com/adinvadim/tiny-code-error
🩵 Simple CodeError JS class (zero deps)
https://github.com/adinvadim/tiny-code-error
Last synced: 15 days ago
JSON representation
🩵 Simple CodeError JS class (zero deps)
- Host: GitHub
- URL: https://github.com/adinvadim/tiny-code-error
- Owner: adinvadim
- License: mit
- Created: 2024-05-10T09:12:31.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-11T11:33:49.000Z (about 1 year ago)
- Last Synced: 2025-06-16T14:16:13.255Z (19 days ago)
- Language: TypeScript
- Size: 38.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# tiny-code-error
[](#License)
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
```sh
yarn add tiny-code-error
``````sh
pnpm i tiny-code-error
```## 🌟 Example
```typescript
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 {}
export const enum ResetPasswordErrorCode {
USER_NOT_FOUND = "app/reset/user-not-found",
UNKNOWN = "app/reset/unknown",
}export class ResetPasswordError extends CodeError {}
```