# @tap-payments/web-error-handing

> Web Error Handling Library

Latest version **1.0.1** (published 2023-12-18) · 0 weekly downloads

## Install

```sh
npm install @tap-payments/web-error-handing
pnpm add @tap-payments/web-error-handing
yarn add @tap-payments/web-error-handing
bun add @tap-payments/web-error-handing
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2023-12-18 |
| First published | 2023-12-11 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Tap Payments |
| Maintainers | mostafaabobakr.tap, i.mousa, mahmoudallam, aya_tap, mud_fahmi, ahmedkaram-tap, haitham-tap, muhammadazhar007, elsharkawy, waqast, hala.q, reham_alsabbagh, kalpanatap, sadbarkhattak |

## Links

- npm: https://www.npmjs.com/package/@tap-payments/web-error-handing
- npm.io page: https://npm.io/package/@tap-payments/web-error-handing

## Recent versions

- 1.0.1 (latest) — 2023-12-18
- 1.0.0 — 2023-12-11

## README

# Web-Error-Handing

It's a package that helps you to handle errors in your web applications.

# Install

This is a [React](https://reactjs.org/) module available through the
[npm registry](https://www.npmjs.com/). Installation is done using the
[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):

```console
npm install @tap-payments/web-error-handing
```

---------------------------- OR -------------------------

```console
yarn add @tap-payments/web-error-handing
```

# Examples

```typescript
import { WebErrorHandler, ClientError } from "@tap-payments/web-error-handing"
try {
  // throw error with only message
  throw new Error("Error Message")
} catch (error) {
  const error = new WebErrorHandler(error)
  console.log(error.getClientError()) // {code: "Unknown", message: "Error Message"}
}

// OR

try {
  // throw error with code and message
  throw new Error("500::Error Message")
} catch (error) {
  const error = new WebErrorHandler(error)
  console.log(error.getClientError()) // {code: "500", message: "Error Message"}
}

// OR

try {
  // network error
  await axios.get("https://api.tap.company/v2/tokens")
} catch (error) {
  // it will return the error object from the response.data.errors and map it to the error object ClientError
  const error = new WebErrorHandler(error)
  console.log(error.getClientError()) // {code: "{{backend_code}}", message: "{{backend_description}}"}
  console.log(error.getCode()) // {{backend_code}}
  console.log(error.getMessage()) // {{backend_description}}
}

// OR

const error = new WebErrorHandler("500::Error Message")
console.log(error.getClientError()) // {code: "500", message: "Error Message"}
console.log(error.getCode()) // "500"
console.log(error.getMessage()) // "Error Message"
```

---
_Source: https://npm.io/package/@tap-payments/web-error-handing · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
