[Haskell-cafe] C++ exception (from *.so) catchable by Haskell??

Nick Rudnick nick.rudnick at gmail.com
Thu Feb 13 23:07:47 UTC 2014


2014-02-13 23:18 GMT+01:00 Brandon Allbery <allbery.b at gmail.com>:

> On Thu, Feb 13, 2014 at 3:57 PM, Nick Rudnick <nick.rudnick at 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 at gmail.com
> ballbery at sinenomine.net
> unix, openafs, kerberos, infrastructure, xmonad
> http://sinenomine.net
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140214/96db5433/attachment.html>


More information about the Haskell-Cafe mailing list