# handle-firebase-error

> Match firebase errors to your own dictionary

Latest version **1.1.0** (published 2020-03-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install handle-firebase-error
pnpm add handle-firebase-error
yarn add handle-firebase-error
bun add handle-firebase-error
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2020-03-29 |
| First published | 2019-06-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 12.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Richard Palmer |
| Maintainers | rdjpalmer |

## Links

- npm: https://www.npmjs.com/package/handle-firebase-error
- Repository: https://github.com/rdjpalmer/handle-firebase-error
- Homepage: https://github.com/rdjpalmer/handle-firebase-error#readme
- Issues: https://github.com/rdjpalmer/handle-firebase-error/issues
- npm.io page: https://npm.io/package/handle-firebase-error

## Recent versions

- 1.1.0 (latest) — 2020-03-29
- 1.0.0 — 2019-06-20

## README

# handle-firebase-error

Library for mapping firebase authentication errors to the originating field and a custom error message.

See `constants.js` for the mapping and error messages which ship with the lib.

## Useage

```bash
yarn add handle-firebase-error
```

```js
import {
  createErrorMessageMapper,
  mapErrorToField,
  ErrorCodes
} from "handle-firebase-error";

const errorDictionary = {
  [ErrorCodes.alreadyInUse]: "Your custom error message"
};

const mapErrorToMessage = createErrorMessageMapper(errorDictionary);

try {
  await firebase.auth().signInWithEmailAndPassword(email, password);
  // Errors with error.code `auth/email-already-in-use`
} catch (error) {
  mapErrorToField(errorMessageMapper(error));
  // { email: "Your custom error message" }
}
```

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