Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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