What's wrong with this code? (#3)
No, you didn't miss #2 - it was about using "throw" rather than "throw e" to preserve the stack information, and I decided it wasn't worth a full post.
This weeks snippet is also related to exception handling. Here's the code:
void UpdateBalance()
{
try
{
balance = newBalance;
db.UpdateBalance(accountID, newBalance);
}
catch (DatabaseException e)
{
throw new Exception(
String.Format("Error updating balance on account {0} to {1}",
accountID, newBalance), e);
}
}
What's wrong with this code?