2014-02-13 23:18 GMT+01:00 Brandon Allbery <allbery.b@gmail.com>:
On Thu, Feb 13, 2014 at 3:57 PM, Nick Rudnick <nick.rudnick@gmail.com> wrote:
std::set_unexpected (myUnexpected);
try {
  throw runtime_error("OOOPS..."); 
}
catch (int) { std::cerr << "caught int\n"; }
catch (...) { std::cerr << "caught some other exception type\n"; }

still is the problem that the STDERR message of myUnexpected doesn't appear – is

You're catching all exceptions so there are no "unexpected" ones to invoke myUnexpected on.

I experimented with commenting out the try/catch wrapping (I am afraid I did not make it clear; btw. the latter doesn't need set_unexpected). So my report refers to (only)

std::set_unexpected (myUnexpected);
throw runtime_error("OOOPS...");
 
there anywhere code applying what you told about?

I'm not sure what you're asking here. My suggestion was essentially to have something like the try/catch you wrote for testing above wrapped around whatever C++ code is throwing the exception, and invoke that try/catch via the FFI.

Oh, I am reworking an FFI interface to C++, and thought it would be neat to give it a nice exception handling, too. As you appeared quite experienced and I consider this to be a practical issue occurring not too seldom, I hoped you might refer to some project, where C++ exception handling is realized.

Thanks, Nick



 
 

--
brandon s allbery kf8nh                               sine nomine associates
allbery.b@gmail.com                                  ballbery@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net