MCPcopy Create free account
hub / github.com/boostorg/leaf / try_catch_

Function try_catch_

include/boost/leaf/handle_errors.hpp:572–606  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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
609template <class TryBlock, class... H>

Callers 2

try_handle_allFunction · 0.85
type try_handle_someMethod · 0.85

Calls 6

unload_resultFunction · 0.85
unpack_error_idFunction · 0.85
current_errorFunction · 0.85
error_infoFunction · 0.70
deactivateMethod · 0.45
unloadMethod · 0.45

Tested by

no test coverage detected