| 570 | { |
| 571 | template <class Ctx, class TryBlock, class... H> |
| 572 | decltype(std::declval<TryBlock>()()) |
| 573 | try_catch_( Ctx & ctx, TryBlock && try_block, H && ... h ) |
| 574 | { |
| 575 | using namespace detail; |
| 576 | BOOST_LEAF_ASSERT(ctx.is_active()); |
| 577 | using R = decltype(std::declval<TryBlock>()()); |
| 578 | try |
| 579 | { |
| 580 | auto r = std::forward<TryBlock>(try_block)(); |
| 581 | unload_result(&r); |
| 582 | return r; |
| 583 | } |
| 584 | catch( std::exception & ex ) |
| 585 | { |
| 586 | ctx.deactivate(); |
| 587 | error_id id = detail::unpack_error_id(ex); |
| 588 | return handle_error_<R>(ctx, error_info(id, &ex, ctx.template get<e_source_location>(id)), std::forward<H>(h)..., |
| 589 | [&]() -> R |
| 590 | { |
| 591 | ctx.unload(id); |
| 592 | throw; |
| 593 | } ); |
| 594 | } |
| 595 | catch(...) |
| 596 | { |
| 597 | ctx.deactivate(); |
| 598 | error_id id = current_error(); |
| 599 | return handle_error_<R>(ctx, error_info(id, nullptr, ctx.template get<e_source_location>(id)), std::forward<H>(h)..., |
| 600 | [&]() -> R |
| 601 | { |
| 602 | ctx.unload(id); |
| 603 | throw; |
| 604 | } ); |
| 605 | } |
| 606 | } |
| 607 | } // namespace detail |
| 608 | |
| 609 | template <class TryBlock, class... H> |
no test coverage detected