Last active
May 18, 2020 00:50
-
-
Save zzdjk6/28da18dfaffc9e5857cffd65f9becd36 to your computer and use it in GitHub Desktop.
More Readable #EarlyReturn
This file contains 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
function doSomething(user, data) { | |
if (!hasPermission(user)) { | |
throw new PermissionDeniedError(); | |
} | |
if (!isNetworkAvailable()) { | |
saveInQueue(user, data); | |
return; | |
} | |
if (!isValid(data)) { | |
throw new DataInvalidError(); | |
} | |
sendToServer(user, data); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment