P
__PPS__
Hi, I've read in documentation to different libraries that their
exception classes aren't subclasses from std::exception, and a separate
catch statement is required for their exceptions. Always, I don't
understand why they do so and want to fix this feature (most of the
time, I go to edit source), even in their docs they write like this:
try {
// Close the database
db.close(0);
// DbException is not subclassed from std::exception, so
// need to catch both of these.
} catch(DbException &e) {
// Error handling code goes here
} catch(std::exception &e) {
// Error handling code goes here
}
and it's obvious that even their comment is repeated. Well, if their
DbException was derived from std::exception but provided extra
functionality we still can use it, and at the same time it's possible
to catch(const std::exception&) to, at least, get some desription of
error
(this piece of code comes from db4 c++ docs)
so, why is that so common that libs provide their hierarchy of
exception classes similar to std::sceptions ??
thanks
exception classes aren't subclasses from std::exception, and a separate
catch statement is required for their exceptions. Always, I don't
understand why they do so and want to fix this feature (most of the
time, I go to edit source), even in their docs they write like this:
try {
// Close the database
db.close(0);
// DbException is not subclassed from std::exception, so
// need to catch both of these.
} catch(DbException &e) {
// Error handling code goes here
} catch(std::exception &e) {
// Error handling code goes here
}
and it's obvious that even their comment is repeated. Well, if their
DbException was derived from std::exception but provided extra
functionality we still can use it, and at the same time it's possible
to catch(const std::exception&) to, at least, get some desription of
error
(this piece of code comes from db4 c++ docs)
so, why is that so common that libs provide their hierarchy of
exception classes similar to std::sceptions ??
thanks