Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jsumners/error-to-html
A simple Node.js module to render an error object as HTML
https://github.com/jsumners/error-to-html
Last synced: about 1 month ago
JSON representation
A simple Node.js module to render an error object as HTML
- Host: GitHub
- URL: https://github.com/jsumners/error-to-html
- Owner: jsumners
- Created: 2016-03-03T18:44:22.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-03-03T18:45:50.000Z (over 8 years ago)
- Last Synced: 2024-10-14T21:56:43.471Z (about 1 month ago)
- Language: JavaScript
- Size: 1.95 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# error-to-html
A simple module for rendering an `Error` object as an HTML snippet.
```javascript
const errorToHtml = require('error-to-html');
const error = new Error('this is an error!');
const html = errorToHtml(error);/*
- message
- stack
Error: this is an error!
at repl:1:13
at REPLServer.defaultEval (repl.js:252:27)
at bound (domain.js:287:14)
at REPLServer.runBound [as eval] (domain.js:300:12)
at REPLServer. (repl.js:417:12)
at emitOne (events.js:82:20)
at REPLServer.emit (events.js:169:7)
at REPLServer.Interface._onLine (readline.js:210:10)
at REPLServer.Interface._line (readline.js:549:8)
at REPLServer.Interface._ttyWrite (readline.js:826:14)
*/
```
```javascript
const errorToHtml = require('error-to-html').errorToHTMLPromise;
const error = new Error('this is an error!');
errorToHtml(error)
.then(console.log)
.catch((e) => {
console.error('You did not supply an error object.');
console.error(e);
});
```
## License
[MIT License](http://jsumners.mit-license.org/)