In general, you are correct, it is a good idea for the UI to give end-users a visual feedback on which actions will be allowed and which actions wouldn't be allowed without having them to click around the interface. If the voting is not allowed, you should see the corresponding parts of the UI grayed out.
However, there are situations when the UI state does not reflect the state of the system. For example, if that deleted answer was by someone else and you did not refresh the interface, the UI wouldn't know that the answer has been deleted. The system needs to be prepared to handle situations such as this one with orange pop-up messages explaining why the action is not allowed.
The orange box code has to be written anyway, but the visual feedback code is optional. The orange box mechanism covers both scenarios (i.e. a deleted entry that looks like a deleted entry, and a deleted entry that does not look like a deleted entry), while the visual feedback covers only the first case. One could argue that using orange boxes alone provides for a unified user experience, so this feedback mechanism is entirely sufficient all by itself.