Posted by
Luigi Ballabio-2 on
URL: http://quantlib.414.s1.nabble.com/exception-handling-on-Unix-tp2545p2555.html
At 09:45 AM 5/21/03 +0200,
[hidden email] wrote:
>Excuse me if this question is too basic but I'm trying to understand how to
>handle Quantlib exceptions on Unix.
>I haven't changed any option to compile quantlib with gcc and when an
>exception is returned I have "core dump" instead of a beautiful error
>message.
Xavier,
I'm not sure I understand. What is it exactly that you're doing?
Are you linking the library to some application? And does the application
properly handle exceptions? I mean, if you just write:
int main() {
throw Error("Boo!");
return 0;
}
the program will just abort---you'll have to write:
int main() {
try {
throw Error("Boo!");
return 0;
} catch (std::exception& e) {
std::cerr << e.what() << std::endl;
return 1;
} catch (...) {
std::cerr << "unknown error" << std::endl;
return 2;
}
}
after which the program will tell you what was the exception. Also, I'm not
sure that even the above will work if some special kind of errors are
raised (such as division by zero). In that case, you'll have to find out
when that happens and add a check before the division...
Was this what you were asking, or am I off the mark?
Later,
Luigi