Skip to content

Instantly share code, notes, and snippets.

@lancejpollard
lancejpollard / example.coffee
Created August 23, 2012 01:50
node.js domain module async error handling
(req, res, next) ->
# req and res are also created in the scope of serverDomain
# however, we'd prefer to have a separate domain for each request.
# create it first thing, and add req and res to it.
reqd = domain.create()
reqd.add(req)
reqd.add(res)
reqd.on "error", (er) ->
console.error "Error", er, req.url
try