J
Joseph Turian
I have a throw as follows:
void bar() {
ostringstream o;
o << foo;
throw o.str();
}
I used to catch it is follows:
void baz() {
try {
bar();
} catch (string s) {
cerr << "CAUGHT";
}
}
That worked just fine. But when I moved the 'try ... catch' block to
main() (which calls baz()), the exception is NOT caught. I just get a
terminate.
Why is that? How can I catch the exception in main?
Thanks,
Joseph
void bar() {
ostringstream o;
o << foo;
throw o.str();
}
I used to catch it is follows:
void baz() {
try {
bar();
} catch (string s) {
cerr << "CAUGHT";
}
}
That worked just fine. But when I moved the 'try ... catch' block to
main() (which calls baz()), the exception is NOT caught. I just get a
terminate.
Why is that? How can I catch the exception in main?
Thanks,
Joseph