Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

youch

Package Overview
Dependencies
Maintainers
0
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

youch

HTML Pretty error stack viewer

  • 3.3.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created

What is youch?

Youch is a package for pretty-printing error objects in Node.js. It provides a user-friendly way to display error stack traces, making it easier to debug issues in your application.

What are youch's main functionalities?

Pretty-Print Error Stack Traces

This feature allows you to catch errors in your Node.js application and render a pretty HTML page with the error stack trace. This makes it easier to identify and fix issues.

const Youch = require('youch');
const http = require('http');

http.createServer((req, res) => {
  try {
    throw new Error('Something went wrong!');
  } catch (error) {
    new Youch(error, req).toHTML().then(html => {
      res.writeHead(200, { 'content-type': 'text/html' });
      res.end(html);
    });
  }
}).listen(3000);

JSON Output

This feature allows you to catch errors and output the error stack trace as a JSON object. This can be useful for logging or for APIs that need to return error details in JSON format.

const Youch = require('youch');
const http = require('http');

http.createServer((req, res) => {
  try {
    throw new Error('Something went wrong!');
  } catch (error) {
    new Youch(error, req).toJSON().then(json => {
      res.writeHead(200, { 'content-type': 'application/json' });
      res.end(JSON.stringify(json));
    });
  }
}).listen(3000);

Other packages similar to youch

Keywords

FAQs

Package last updated on 07 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc