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

ouch

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ouch

Javascript error handling for cool kids

  • 0.1.0-alpha
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
18K
increased by2.89%
Maintainers
1
Weekly downloads
 
Created
Source

Ouch

NodeJS errors for cool kids

npm version Build Status Documentation Status


Ouch!

Ouch is a NodeJS implementation of PHP's Whoops library. It's not an exact port of Whoops, but implements similar functionality and uses same front end resources in some of its error handlers. It is an error handler base/framework for NodeJs. Out-of-the-box, it provides a pretty error interface that helps you debug your web projects, but at heart it's a simple yet powerful stacked error handling system.

Pretty page handler demo

Blue theme

Orange theme

##Installation

The source is available for download from GitHub. Alternatively, you can install using Node Package Manager (npm):

npm install ouch

Usage examples

    // With PrettyPageHandler
    http.createServer(function nsjfkj(req, res){

        if (req.url === '/favicon.ico') {
            res.writeHead(200, {'Content-Type': 'image/x-icon'} );
            res.end();
            return;
        }

        var d = domain.create();

        d.on('error', function(e){
            var ouchInstance = (new Ouch).pushHandler(
                    new Ouch.handlers.PrettyPageHandler('orange', null, 'sublime')
                );
            ouchInstance.handleException(e, req, res, function (output) {
                console.log('Error handled properly')
            });
        });
        d.run(function(){

            // your application code goes here

        });

    }).listen('1338', 'localhost');


    // With custom callback handler
    var ouchInstance = (new Ouch).pushHandler(
        function(next, exception, request, response){

            // custom handler logic

            next();
        });

    ouchInstance.handleException(e, req, res, function (output) {
        console.log('Error handled properly')
    });

For more options, take a look at the API Documentation and the list of available handers below.

Available Handlers

Ouch currently ships with the following built-in handlers, available in the require("ouch").hanlers namespace:

  • PrettyPageHandler - Shows a pretty error page when something goes pants-up
  • JsonResponseHandler - Captures exceptions and returns information on them as a JSON string.

Todo

- Add more handlers.

Keywords

FAQs

Package last updated on 14 Mar 2015

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