Skip to content

Instantly share code, notes, and snippets.

@mcsee
Last active October 12, 2025 15:13
Show Gist options
  • Save mcsee/cc4bb614c78c7da080657ca91dff7cb4 to your computer and use it in GitHub Desktop.
Save mcsee/cc4bb614c78c7da080657ca91dff7cb4 to your computer and use it in GitHub Desktop.
This gist belongs to Clean Code Cookbook http://cleancodecookbook.com By Maximiliano Contieri http://maximilianocontieri.com
public void Withdraw(int amount) {
if (amount > Balance) {
throw new Exception("Insufficient funds");
// You might want to show this error to end users
}
if (connection == null) {
throw new Exception("Database not available");
// Internal error, log and notify operators.
// Fail with a more generic error
}
Balance -= amount;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment