Hi folks, I'm using some code which catches exceptions thrown from signals, like shown here: http://blog.ale-re.net/2007/04/exception-handling.html.
Now, I'm having some problems: I have a chain of catch blocks for different exception types, but the exception returned is always caught as a generic std::exception, even though it is most definitely of more specific type. Here's some of the code:
try {
}
catch (Xmms::connection_error &ex) {
qDebug("Caught connection_error: %s",ex.what());
return false;
}
catch (Xmms::result_error &ex) {
qDebug("Caught result_error: %s",ex.what());
return false;
}
catch (std::exception &ex) {
qDebug("Caught generic exception: %s",ex.what());
}
catch (...) {
qDebug("Unknown exception!");
abort();
}
try {
return QApplication::notify(receiver, event);
}
catch (Xmms::connection_error &ex) {
qDebug("Caught connection_error: %s",ex.what());
return false;
}
catch (Xmms::result_error &ex) {
qDebug("Caught result_error: %s",ex.what());
return false;
}
catch (std::exception &ex) {
qDebug("Caught generic exception: %s",ex.what());
}
catch (...) {
qDebug("Unknown exception!");
abort();
}
To copy to clipboard, switch view to plain text mode
The type of exception thrown IS the more specific type, but is, for some reason, caught in the less specific handler.
Is this a problem with Qt, or am I just mangling C++?
Thanks very much for your help.
Bookmarks