Skip to content

Instantly share code, notes, and snippets.

@rishispeets
Created April 26, 2017 08:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rishispeets/6cbfa6be7e63979a05b51e3f3d467004 to your computer and use it in GitHub Desktop.
Save rishispeets/6cbfa6be7e63979a05b51e3f3d467004 to your computer and use it in GitHub Desktop.
Node.js style error callback handling
var fs = require('fs')
fs.readFile('/Does/not/exist', handleFile)
function handleFile (error, file) {
if (error) return console.error('Uhoh, there was an error', error)
// otherwise, continue on and use `file` in your code
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment