# deserialize-error

> convert Plain Object to Error Object

Latest version **0.0.3** (published 2016-09-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install deserialize-error
pnpm add deserialize-error
yarn add deserialize-error
bun add deserialize-error
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2016-09-17 |
| First published | 2016-09-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Sho Hashimoto |
| Maintainers | shokai |
| Keywords | error, deserialize, serialize |

## Links

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

## 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

- 0.0.3 (latest) — 2016-09-17
- 0.0.2 — 2016-09-11
- 0.0.1 — 2016-09-10

## README

# deserialize-error

convert Plain Object to Error Object

- https://github.com/shokai/deserialize-error
- https://npmjs.com/package/deserialize-error

[![CircleCI](https://circleci.com/gh/shokai/deserialize-error.svg?style=svg)](https://circleci.com/gh/shokai/deserialize-error)


## Usage

Serialize Error's name, message and stack-trace with [serialize-error npm](https://www.npmjs.com/package/serialize-error), then deserialize.

```javascript
import serializeError from 'serialize-error'
import deserializeError from 'deserialize-error'

const err = new Error('ouch')
const obj = serializeError(err)
const err2 = deserializeError(obj)

assert.equal(err.name, err2.name)
assert.equal(err.message, err2.message)
assert.equal(err.stack, err2.stack)
assert.equal(err.toString(), err2.toString())
```


It also works with custom error and json format.

```javascript
class ArgumentError extends Error {
  constructor (message) {
    super(message)
    this.name = 'ArgumentError'
  }
}

const err = new ArgumentError('"name" should be a string!!')
const err2 = deserializeError(
  JSON.parse(
    JSON.stringify(
      serializeError(err)
    )
  )
)

assert.equal(err.name, err2.name)
assert.equal(err.message, err2.message)
assert.equal(err.stack, err2.stack)
assert.equal(err.toString(), err2.toString())
```

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