Much has been said, Iβll just add something on my part.
In your case, both cases are true, except that I would like to divide it into two levels: logic and representation. So your logic level is:
doLogic() { if (n > 5) { throw "n is greater than 5"; }
and your viewing level can do:
try { doLogic() } catch (const char *e) { MessageBox(0, e, 0, 0); return; }
But then again, as another said: the most important thing is where the Russian comes from. If you expect it to be greater than 5, just use if () else, not the exception. But if n is always less than 5, and if it is more than 5, then something is wrong with your system, use exceptions.
Katalonis Nov 05 '10 at 10:58
source share