Skip to content

Instantly share code, notes, and snippets.

@pyykkis
Created July 2, 2013 10:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pyykkis/5908214 to your computer and use it in GitHub Desktop.
Save pyykkis/5908214 to your computer and use it in GitHub Desktop.
How james.js error handling should be done?
// james-coffee/index.js
var james = require('james'),
coffee = require('coffee-script');
coffee.createStream = function() {
return james.createTransformation(function(content, callback) {
// Process the file content and call the callback with the result.
try {
res = coffee.compile(content);
callback(null, res);
} catch(err) {
callback(err, null);
}
});
};
james.read('./hello.coffee')
.transform(coffee.createStream)
.write(process.stdout);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment