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

Alexander Kjeldaas alexander.kjeldaas at gmail.com
Thu Feb 13 12:11:02 UTC 2014


Two approaches:

1. Use set_unexpected.
http://www.cplusplus.com/reference/exception/set_unexpected/

2. Wrap your FFI code in try/catch.

Alexander


On Thu, Feb 13, 2014 at 12:43 PM, Nick Rudnick <nick.rudnick at gmail.com>wrote:

> Dear all,
>
> after trying around a while this seems to be a good question for
> Haskell-cafe to me: Is somewhere a place (e.g. some Hackage package) where
> intercepting exceptions from C++ library code is done, so one can look
> *how* it is done?
>
> Generally, it is the following:
> 1) Injecting code that throws a an exception in C++ library code, e.g.,
>
> throw runtime_error("OOOPS...");
>
>
> 2) then, I tried out everything in reach (Haskell docs, Hackage interfaces
> to C++ considered to be well-done) to get it caught (try, catch, bracket,
> finally; various exception types; forkOS).
>
> 3) To my surprise, every time the output stays the same:
>
> terminate called after throwing an instance of 'std::runtime_error'
>   what():  OOOPS...
>
> Is it possible at all to get a grip of this? Is there some place where it
> is done? Does the terminate call already happen with the C++ execution?
>
> Any comment welcome, cheers, Nick
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140213/1f967573/attachment.html>


More information about the Haskell-Cafe mailing list