# array-to-error

> Create an error from an array of error messages

Latest version **1.1.1** (published 2016-06-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install array-to-error
pnpm add array-to-error
yarn add array-to-error
bun add array-to-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.1 |
| Published | 2016-06-21 |
| First published | 2015-10-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Shinnosuke Watanabe |
| Maintainers | shinnn |
| Keywords | err, error, arr, array, convert, join, concat, concatenate, concatenation, browser |

## Links

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

## Dependencies (1)

- [array-to-sentence](https://npm.io/package/array-to-sentence.md) ^1.1.0

## 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.1.1 (latest) — 2016-06-21
- 1.1.0 — 2016-06-08
- 1.0.0 — 2015-10-06
- 0.0.2 — 2015-10-06

## README

# array-to-error

[![NPM version](https://img.shields.io/npm/v/array-to-error.svg)](https://www.npmjs.com/package/array-to-error)
[![Build Status](https://travis-ci.org/shinnn/array-to-error.svg?branch=master)](https://travis-ci.org/shinnn/array-to-error)
[![Coverage Status](https://img.shields.io/coveralls/shinnn/array-to-error.svg)](https://coveralls.io/github/shinnn/array-to-error?branch=master)
[![Dependency Status](https://david-dm.org/shinnn/array-to-error.svg)](https://david-dm.org/shinnn/array-to-error)
[![devDependency Status](https://david-dm.org/shinnn/array-to-error/dev-status.svg)](https://david-dm.org/shinnn/array-to-error#info=devDependencies)

Create an error from an array of error messages

```javascript
const arrayToError = require('array-to-error');

const error = arrayToError(['tranling comma on line 1', 'unexpected "(" on line 2']);
error.message; //=> 'tranling comma on line 1\nunexpected "(" on line 2'
error.reasons; //=> ['tranling comma on line 1', 'unexpected "(" on line 2']
```

## Installation

#### [npm](https://www.npmjs.com/)

```
npm install array-to-error
```

#### [Bower](https://bower.io/)

```
bower install array-to-error
```

## API

```javascript
const arrayToError = require('array-to-error');
```

### arrayToError(*messages* [, *constructor*])

*messages*: `Array` of strings  
*constructor*: `Object` (One of the [error constructors](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error#Error_types). [`Error`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error) by default)  
Return: `Object` (error instance)

It returns an instance of error whose `message` is made from its first argument joined with `\n`, and has an additional `reasons` property, the same value as its first argument.

The second argument is used as an error constructor.

```javascript
const arrayToError = require('array-to-error');

const error = arrayToError(['foo', 'bar'], TypeError);
error.message; //=> 'foo\nbar'
error.reasons; //=> ['foo', 'bar']
error.constructor; //=> TypeError
```

## License

Copyright (c) 2015 - 2016 [Shinnosuke Watanabe](https://github.com/shinnn)

Licensed under [the MIT License](./LICENSE).

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