RishiSpeets
4/26/2017 - 8:40 AM

Node.js style error callback handling

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
 }