Last active
May 17, 2020 03:48
-
-
Save zzdjk6/7c34330a06dfb78d6bd301f9faafa21a to your computer and use it in GitHub Desktop.
Less 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)) { | |
if (isNetworkAvailable()) { | |
if (isValid(data)) { | |
sendToServer(user, data); | |
} else { | |
throw new DataInvalidError(); | |
} | |
} else { | |
saveInQueue(user, data); | |
} | |
} else { | |
throw new PermissionDeniedError(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment