Boost logo

Boost Users :

Subject: [Boost-users] Exceptions and throwing across module boundaries
From: Josh Faust (jfaust_at_[hidden])
Date: 2009-11-11 17:08:48


One of the problems with exceptions that we've run into recently is throwing
across module boundaries -- we hit a case where an exception thrown in one
module cannot be caught as anything but a std::exception in a module
compiled with different settings (same compiler -- gcc 4.2). This is of
course item #62 in "C++ Coding Standards".

Since we'd prefer to use exceptions rather than return codes as our error
reporting mechanism, I'm currently investigating possible solutions to
this. I was hoping to find something applicable boost, but it looks like
boost doesn't differentiate between throwing in a header vs. throwing in a
module -- for example, Boost.Thread has a few throw statements in cpp files
(both in posix and win32). Is this just an issue that hasn't been enough of
a problem to address?

The approach I am considering is wrapping module interfaces with a
translation layer which turns an exception to an error code, which is
re-translated back to an exception in the header used by client code. Has
anyone done anything similar? Is there something in boost like this
already? (I was hoping to find something in Boost.Exception, but it does not
appear to solve this situation).

Thanks

Josh



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net