Skip to content
This repository has been archived by the owner on Nov 7, 2018. It is now read-only.

nsabovic/emit-error-eh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Emit error, eh?

A tool to find Streams that don't have handlers for their error event.

Why?

error events are special. If not handled, they throw. When they do, you get an exception, and since most often events are used to throw asynchronously, this means you get an uncaught exception.

Why not all EventEmitters?

Not all EventEmitters can emit errors in the first place. Streams cover sockets, requests, responses and files. That's enough for now.

How does it work?

You write:

var e = require('emit-error-eh');

and optionally:

e.logger = function(err) { /* console.log() is default */};

// Add some stack traces which you want ignored.
e.ignored = [
  [
    { name: 'new Socket', module: 'net.js'},
    { name: 'Agent.createConnection', module: 'net.js'},
    { name: 'Agent.createSocket', module: 'http.js'},
    { name: 'Agent.addRequest', module: 'http.js'},
    { name: 'new ClientRequest', module: 'http.js'},
  ],
  [
    { name: 'WriteStream.Socket', module: 'net.js'},
    { name: 'new WriteStream', module: 'tty.js'},
    { name: 'createWritableStdioStream', module: 'node.js'},
  ]
];

Voila. Your logger function will be called every time someone creates a Stream without assigning it an error handler.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published