Hello I am trying to get a clearer understanding of when to use exceptions and when to not use them. I will give a few case scenarios. Can you let me know which cases I should use exception, and explain why I should or should not? (note: this is not a homework problem).
Scenario 1: I design a computer game where each unit can move to a square on a board. However, some square can be blocked. Should I throw a SquareIsBlockedException to prevent the movement of the unit?
Scenario 2: I insert a record to the database, however it fails because there the unique ID is already present. It throws a DuplicateIDException.
Why should I use exceptions for scenario 2, but not for scenario 1?