Boost logo

Boost Users :

Subject: Re: [Boost-users] [exception, serialization] transporting exceptions
From: Brian Budge (brian.budge_at_[hidden])
Date: 2012-10-05 19:07:45


On Fri, Oct 5, 2012 at 3:45 PM, Emil Dotchevski
<emildotchevski_at_[hidden]> wrote:
> On Fri, Oct 5, 2012 at 2:10 PM, Brian Budge <brian.budge_at_[hidden]> wrote:
>>
>> Hi all -
>>
>> I like that boost::exception provides a mechanism to copy exceptions.
>> This can be used to transport an exception across thread boundaries,
>> which is nice. I'm running a program that can optionally start nodes
>> using MPI to do back-end computations. I'd like to be able to "copy"
>> the exception from one node to another. Are there any existing tools
>> for something like a serialization of these kinds of exceptions? In
>> non-MPI mode, I'd like to transport the exception across thread
>> boundaries, pass it through some functions (causing actions to be
>> taken along the way), and then finally to rethrow the exception. In
>> MPI mode I want all of that PLUS, in place of one of the function
>> calls, I'd like to transport the exception across MPI in some way.
>>
>> Are there any semi-automatic tools already in existence that will get
>> me this (or close)? Or do I need to implement boost serialization for
>> my entire exception hierarchy? If I do the latter, it seems I will
>> need to operator new the exception, and will not easily be able to
>> know when I can delete in a catch?
>
> I'm not aware of any existing tools but in principle it could be done.
> It would require registering the permissible exception types with a
> serialization library, then serializing them through a pointer to a
> base type that you catch. Keep in mind that at the point of the catch,
> the static type by which you're referring to the exception object may
> not have an accessible copy constructor.
>
> Emil Dotchevski
> Reverge Studios, Inc.
> http://www.revergestudios.com/reblog/index.php?n=ReCode

Thanks Emil. I'll have to decide if it's worth the pain for
intra-process transport :)

Is there any way to force a behavior where any exception derived from
a given exception, myexception, will act as though it were thrown
wrapped with enable_current_exception? What exactly does
enable_current_exception do? Does it make an exception_ptr and put it
in thread local storage?

Thanks,
  Brian


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