Last active
December 23, 2015 06:09
-
-
Save swallentin/6592121 to your computer and use it in GitHub Desktop.
Before:
Callback function implementation that does not use guard return statements. After:
Callback function implementation that uses guard return statements. Inspiration, http://www.bennadel.com/blog/2323-Use-A-Return-Statement-When-Invoking-Callbacks-Especially-In-A-Guard-Statement.htm
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
if (err) { | |
return callback(err); | |
} | |
if (!udfDocument) { | |
var msg = 'Could not find UDF document for importId: ' + udfId; | |
return callback(new Error(msg)); | |
} | |
return callback(udfDocument); |
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
if (err) { | |
callback(new Error(err)); | |
} | |
else if (!udfDocument) { | |
var msg = 'Could not find UDF document for importId: ' + udfId; | |
callback(new Error(msg)); | |
} else { | |
callback(udfDocument); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment