Opened 11 years ago

Closed 6 years ago

#5604 closed Feature Requests (fixed)

Boost.Phoenix: Provide access to thrown exception in catch handler

Reported by: Stuart Dootson <stuart.dootson@…> Owned by: Thomas Heller
Milestone: Component: phoenix
Version: Boost 1.47.0 Severity: Problem
Keywords: exception placeholder Cc: braden@…

Description

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...

Change History (9)

comment:1 by Thomas Heller, 11 years ago

Milestone: To Be DeterminedBoost 1.48.0
Status: newassigned
Version: Boost 1.44.0Boost 1.47.0

comment:2 by Thomas Heller, 11 years ago

Milestone: Boost 1.48.0To Be Determined

comment:3 by Kohei Takahashi <flast@…>, 8 years ago

I implemented this feature and has been merged, see h ttps://github.com/boostorg/phoenix/pull/13.

comment:4 by John Fletcher <J.P.Fletcher@…>, 8 years ago

This is now on develop. It has missed the cutoff for Boost 1.58.0 but will be in the next release of Boost. Thanks to Kohei Takakashi

in reply to:  4 comment:5 by John Fletcher <J.P.Fletcher@…>, 8 years ago

Replying to John Fletcher <J.P.Fletcher@…>:

This is now on develop. It has missed the cutoff for Boost 1.58.0 but will be in the next release of Boost. Thanks to Kohei Takakashi

Sorry, that should be Kohei Takahashi.

comment:6 by Braden McDaniel <braden@…>, 7 years ago

Cc: braden@… added

comment:7 by Braden McDaniel <braden@…>, 7 years ago

This doesn't appear to have made it into Boost 1.59.0, either.

comment:8 by John Fletcher, 7 years ago

This has now been moved to master and so will be in 1.60.0

comment:9 by Kohei Takahashi, 6 years ago

Milestone: To Be Determined
Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.