[Boost-bugs] [Boost C++ Libraries] #5604: Boost.Phoenix: Provide access to thrown exception in catch handler

Subject: [Boost-bugs] [Boost C++ Libraries] #5604: Boost.Phoenix: Provide access to thrown exception in catch handler
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-06-12 18:22:34


#5604: Boost.Phoenix: Provide access to thrown exception in catch handler
-------------------------------------------------------+--------------------
 Reporter: Stuart Dootson <stuart.dootson@…> | Owner: theller
     Type: Feature Requests | Status: new
Milestone: To Be Determined | Component: phoenix
  Version: Boost 1.44.0 | Severity: Problem
 Keywords: exception placeholder |
-------------------------------------------------------+--------------------
 I've been using Phoenix (the one that came with 1.44 - that's Phoenix v2?)
 for a bit, as a Boost.Lambda replacement, mostly happily. But I've come
 across a scenario I don't think Phoenix caters for, namely accessing an
 exception from a catch_ body, something like this:

 {{{
 std::vector<std::string> errors;
 using namespace boost::phoenix;
 using namespace boost::phoenix::arg_names;
 std::for_each(changes.begin(), changes.end(),
    try_
    [
       bind(&SomeClass::AddChange, this, arg1, std::string())
    ]
    .catch_<std::runtime_error>()`
    [
       push_back(ref(errors), bind(&std::runtime_error::what, /* Can I
 access the exception that's been thrown? */))
    ]);
 }}}

 I want to aggregate any error information thrown by
 {{{SomeClass::AddChange}}} in the {{{errors}}} vector, to be rethrown
 after the for_each. In Boost.Lambda, I'd be able to use the `_e`
 placeholder to access the exception object, but there seems to be no way
 of doing so in Phoenix?

 Adding a similar placeholder to give access to the exception object would
 be a very useful addition to Phoenix...

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/5604>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:06 UTC