Skip to content

Instantly share code, notes, and snippets.

@seanstrom
Last active August 29, 2015 14:13
Show Gist options
  • Save seanstrom/99966c72d7a0379d4944 to your computer and use it in GitHub Desktop.
Save seanstrom/99966c72d7a0379d4944 to your computer and use it in GitHub Desktop.
Async JS/Node - Node CPS More Error Handling example
var fs = require('fs')
, path = 'my_file.txt'
function getFile(path, callback) {
fs.readFile(path, function(err, data) {
if(err){
return callback(err)
}
var wrapperMessage = {coolStuff: true, data: data}
callback(null, wrapperMessage)
})
}
getFile(path, function(err, message) {
if(err) {
console.error(err)
} else {
console.log(message)
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment