https://github.com/tiaanduplessis/err-replacer
JSON stringify replacer to add support for error serialization
https://github.com/tiaanduplessis/err-replacer
json replacer stringify
Last synced: 10 months ago
JSON representation
JSON stringify replacer to add support for error serialization
- Host: GitHub
- URL: https://github.com/tiaanduplessis/err-replacer
- Owner: tiaanduplessis
- License: mit
- Created: 2017-08-03T11:02:28.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2019-06-02T22:41:29.000Z (about 7 years ago)
- Last Synced: 2025-06-15T07:37:51.086Z (about 1 year ago)
- Topics: json, replacer, stringify
- Language: JavaScript
- Size: 57.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
err-replacer
JSON stringify replacer to add support for error serialization
Table of Contents
Table of Contents
## Install
[](https://greenkeeper.io/)
```sh
$ npm install err-replacer
# OR
$ yarn add err-replacer
```
## Usage
```js
const errReplacer = require('err-replacer')
const err = new Error('Foo')
console.log(JSON.stringify(err, errReplacer))
// {"stack":"Error: Foo\n at Object. (/Users/Tiaan/Workspace/err-replacer/index.js:16:13)\n at Module._compile (module.js:569:30)\n
// at Object.Module._extensions..js (module.js:580:10)\n at Module.load (module.js:503:32)\n at tryModuleLoad (module.js:466:12)\n at Functio
// n.Module._load (module.js:458:3)\n at Function.Module.runMain (module.js:605:10)\n at startup (bootstrap_node.js:158:16)\n at bootstrap_nod
// e.js:575:3","message":"Foo"}
```
## Contributing
Contributions are welcome!
1. Fork it.
2. Create your feature branch: `git checkout -b my-new-feature`
3. Commit your changes: `git commit -am 'Add some feature'`
4. Push to the branch: `git push origin my-new-feature`
5. Submit a pull request :D
Or open up [a issue](https://github.com/tiaanduplessis/err-replacer/issues).
## License
Licensed under the MIT License.