# fe-error-helper

> FE error mapper

Latest version **1.0.5** (published 2021-12-24) · ISC license · 0 weekly downloads

## Install

```sh
npm install fe-error-helper
pnpm add fe-error-helper
yarn add fe-error-helper
bun add fe-error-helper
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2021-12-24 |
| First published | 2021-12-23 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 18.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | itersh |
| Maintainers | itersh |
| Keywords | error, mapper, antd |

## Links

- npm: https://www.npmjs.com/package/fe-error-helper
- npm.io page: https://npm.io/package/fe-error-helper

## Alternatives

- [@sentry/react-native](https://npm.io/package/@sentry/react-native.md) — 2.6M weekly downloads
- [@ardatan/aggregate-error](https://npm.io/package/@ardatan/aggregate-error.md) — 708.1K weekly downloads
- [custom-error-generator](https://npm.io/package/custom-error-generator.md) — 2.0K weekly downloads
- [@technik-sde/prosemirror-recreate-transform](https://npm.io/package/@technik-sde/prosemirror-recreate-transform.md) — 1.5K weekly downloads
- [@suchipi/error-utils](https://npm.io/package/@suchipi/error-utils.md) — 78 weekly downloads

## Recent versions

- 1.0.5 (latest) — 2021-12-24
- 1.0.4 — 2021-12-23

## README

# error-helper

#### To start using:

```
yarn add @axmit/error-helper
```

```js
import { errorMapper } from '@axmit/error-helper';

axios.interceptors.response.use(
  response => response.data,
  error => errorMapper
);
```

##### If you want show popup

```js
import { errorMapper } from '@axmit/error-helper';
import { message } from 'antd';

...

axios.interceptors.response.use(
  response => response.data,
  error => errorMapper(error, { showError: message.error, defaultError: 'An error occurred, please try again later' })
);
```

##### Examples for different params

```js
axios.interceptors.response.use(
  response => response.data,
  error => {
    const popupConfig = { showError: message.error, defaultError: EBaseErrorMessage.Default };
    const codesConfig = {
      withValidations: [...defaultCodesWithValidations, EErrorStatus.RetryWith],
      withPopupMessage: [EErrorStatus.PayloadTooLarge]
    };

    return errorMapper(error, popupConfig, codesConfig, t);
  }
);
```

##### Examples with antd4 forms (where error has type IError)

```js
const LoginFormComponent: React.FC<AllProps> = props => {
    const { customerModel } = props;
    const { errors, params, data } = customerModel;
    const { fields } = useFormMapper(['name', 'email', 'password'], data, params, errors);
    ...

    return (
        <Form onFinish={login} fields={fields}>
```

---
_Source: https://npm.io/package/fe-error-helper · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
