Last active
          October 12, 2025 15:13 
        
      - 
      
- 
        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 
  
        
  
    
      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
    
  
  
    
  | 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