'use strict';

// deals with node.js domains, for gracefully handling errors to prevent application crashes on throwing of exceptions

var domain = require('domain');
var d = domain.create();

module.exports = {
    handle: function(uncaughtFunction) {
        d.on('error', function(err) {
            logger.error(err);
        });

        d.run(function() {
            uncaughtFunction();
        });
    }

};
