Re: throw std::invalid_argument
On Feb 20, 6:43 am, red floyd <no.spam.h...@example.com> wrote:
mlt wrote:
In my code I use throw:
if (someCondition) {
std::cout << "time to throw!\n";
throw std::invalid_argument("very bad error!");
}
I then test for what happens when someCondition is true. "time to throw=
!"
gets printed but "very bad error!" is not printed. A box just pops up
saying:
Debug Error!
Program: ...
This application has requested the Runtime to terminate.....
(Press retry to debug application)
Should "very bad error!" not pop up somewhere?
Why would you expect that? Are you catching invalid_argument and
sending something to cout? If you're not catching invalid_argument (or
its parent), then you're going to hit std::unexpected, which for your
compiler, apparently pops up the Runtime Termination dialog.
That'll teach me to post while half asleep. If you don't catch your
exception, you'll go to std::terminate, not std::unexpected.