Created
July 9, 2014 19:17
-
-
Save mde/5e01d8d5a46c0a8a9e0f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http') | |
, domain = require('domain') | |
, riakpbc = require('./index') | |
, riak = riakpbc.createClient({host: 'localhost', port: 8087}); | |
http.createServer(function (req, res) { | |
var dmn = domain.create(); | |
dmn.on('error', function (err) { | |
console.dir(arguments); | |
console.log('Domain caught error'); | |
res.writeHead(200, {'Content-Type': 'text/plain'}); | |
res.end(err.message + '\n'); | |
}); | |
dmn.run(function () { | |
/* | |
setTimeout(function () { | |
// Domain correctly catches this | |
throw new Error('HELP COMPUTER'); | |
}, 0); | |
*/ | |
riak.getServerInfo(function (err, reply) { | |
console.log('Riak returned:', arguments); | |
// Domain does not catch this | |
throw new Error('Uhhh ... what the hell?'); | |
}); | |
}); | |
}).listen(1337, '127.0.0.1'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment