value-error

Extract the data from an Error to a plain object

Usage no npm install needed!

<script type="module">
  import valueError from 'https://cdn.skypack.dev/value-error';
</script>

README

value-error Build Status

Extract the data from an Error to a plain object

Install

$ npm install --save value-error

Usage

var valueError = require('value-error')
var err = new Error('OH NO')
err.data = {foo: 'bar'}
valueError(err)
//=> {message: 'OH NO', data: {foo: 'bar'}}

API

valueError(err) -> object

err

Required
Type: error

An Error instance to be copied into a plain object. All enumerable properties will be copied. The message will be copied even if it is non-enumerable. Other non-enumerable/inherited properties like stack and name will not be included.

License

MIT © Ben Drucker