Skip to content

Instantly share code, notes, and snippets.

@nanha
Created March 10, 2013 00:29
Show Gist options
  • Save nanha/5126502 to your computer and use it in GitHub Desktop.
Save nanha/5126502 to your computer and use it in GitHub Desktop.
domain error handler + bind function
function User() {
this.name = 'nanha';
}
var Nanha = new User();
var fs = require('fs');
var domain = require('domain').create();
domain.on('error', function(err) {
console.log('=====');
console.log(this);
}.bind(Nanha));
fs.readFile('./adsfasdf', domain.bind(function(err, data) {
if (err) throw new Error(err);
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment