@d2.js/youch

4.2.3Β β€’Β PublicΒ β€’Β Published

Youch!

Pretty error reporting for Node.js πŸš€ (Modified for D2.js & SSR Bundles)




Youch is inspired by Whoops but with a modern design. Reading stack trace of the console slows you down from active development. Instead Youch print those errors in structured HTML to the browser.

Features

  1. HTML reporter
  2. JSON reporter, if request accepts a json instead of text/html.
  3. Sorted frames of error stack.

Installation

npm i --save @d2.js/youch

Basic Usage

Youch is used by AdonisJs and D2.js, but it can be used by express or raw HTTP server as well.

const Youch = require("@d2.js/youch");
const http = require("http");

http
  .createServer(function (req, res) {
    // PERFORM SOME ACTION
    if (error) {
      const youch = new Youch(error, req);

      youch.toHTML().then((html) => {
        res.writeHead(200, { "content-type": "text/html" });
        res.write(html);
        res.end();
      });
    }
  })
  .listen(8000);

Package Sidebar

Install

npm i @d2.js/youch

Weekly Downloads

1

Version

4.2.3

License

MIT

Unpacked Size

45 kB

Total Files

4

Last publish

Collaborators

  • nkduy