Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/adinvadim/tiny-code-error
🩵 Simple CodeError JS class (zero deps)
https://github.com/adinvadim/tiny-code-error
Last synced: about 2 months 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 (8 months ago)
- Default Branch: main
- Last Pushed: 2024-05-11T11:33:49.000Z (8 months ago)
- Last Synced: 2024-11-12T21:42:33.439Z (2 months 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: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](#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 {}
```