Created
April 26, 2017 08:40
-
-
Save rishispeets/6cbfa6be7e63979a05b51e3f3d467004 to your computer and use it in GitHub Desktop.
Node.js style error callback handling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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