Package Exports
- array-to-error
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (array-to-error) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
array-to-error
Create an error instance from an array of error messages
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 install array-to-errorAPI
const arrayToError = require('array-to-error');arrayToError(messages [, constructor])
messages: Array of strings
constructor: Object (One of the error constructors. 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.
const arrayToError = require('array-to-error');
const error = arrayToError(['foo', 'bar'], TypeError);
error.message; //=> 'foo\nbar'
error.reasons; //=> ['foo', 'bar']
error.constructor; //=> TypeErrorLicense
Copyright (c) 2015 Shinnosuke Watanabe
Licensed under the MIT License.