inline exception_ptr current_exception() { try { return exception_ptr(exception_detail::current_exception_impl()); } catch( std::bad_alloc & ) { } catch( ... ) { try { return exception_ptr(exception_detail::current_exception_std_exception(std::bad_exception())); } catch( std::bad_alloc & ) { } catch( ... ) { BOOST_ASSERT(0); } } return exception_ptr(exception_ptr::bad_alloc_tag()); }
inline exception_ptr current_exception_std_exception( T const & e1 ) { if( boost::exception const * e2 = dynamic_cast<boost::exception const *>(&e1) ) return exception_ptr(exception_detail::make_clone(current_exception_std_exception_wrapper<T>(e1,*e2))); else return exception_ptr(exception_detail::make_clone(current_exception_std_exception_wrapper<T>(e1))); }
inline exception_ptr current_exception_unknown_std_exception( std::exception const & e ) { if( boost::exception const * be = dynamic_cast<boost::exception const *>(&e) ) return exception_ptr(exception_detail::make_clone(unknown_exception(*be))); else return current_exception_unknown_exception(); }
void state::handle_reply( const response& response ) { auto await = _awaiting.find( response.id ); FC_ASSERT( await != _awaiting.end(), "Unknown Response ID: ${id}", ("id",response.id)("response",response) ); if( response.result ) await->second->set_value( *response.result ); else if( response.error ) { await->second->set_exception( exception_ptr(new FC_EXCEPTION( exception, "${error}", ("error",response.error->message)("data",response) ) ) ); } else await->second->set_value( fc::variant() ); _awaiting.erase(await); }
inline exception_ptr current_exception_impl() { exception_detail::clone_base const * e=0; switch( exception_detail::clone_current_exception(e) ) { case exception_detail::clone_current_exception_result:: success: { BOOST_ASSERT(e!=0); return exception_ptr(shared_ptr<exception_detail::clone_base const>(e)); } case exception_detail::clone_current_exception_result:: bad_alloc: { BOOST_ASSERT(!e); return exception_detail::exception_ptr_static_exception_object<bad_alloc_>::e; } case exception_detail::clone_current_exception_result:: bad_exception: { BOOST_ASSERT(!e); return exception_detail::exception_ptr_static_exception_object<bad_exception_>::e; } default: BOOST_ASSERT(0); case exception_detail::clone_current_exception_result:: not_supported: { BOOST_ASSERT(!e); try { throw; } catch( exception_detail::clone_base & e ) { return exception_ptr(shared_ptr<exception_detail::clone_base const>(e.clone())); } catch( std::domain_error & e ) { return exception_detail::current_exception_std_exception(e); } catch( std::invalid_argument & e ) { return exception_detail::current_exception_std_exception(e); } catch( std::length_error & e ) { return exception_detail::current_exception_std_exception(e); } catch( std::out_of_range & e ) { return exception_detail::current_exception_std_exception(e); } catch( std::logic_error & e ) { return exception_detail::current_exception_std_exception(e); } catch( std::range_error & e ) { return exception_detail::current_exception_std_exception(e); } catch( std::overflow_error & e ) { return exception_detail::current_exception_std_exception(e); } catch( std::underflow_error & e ) { return exception_detail::current_exception_std_exception(e); } catch( std::ios_base::failure & e ) { return exception_detail::current_exception_std_exception(e); } catch( std::runtime_error & e ) { return exception_detail::current_exception_std_exception(e); } catch( std::bad_alloc & e ) { return exception_detail::current_exception_std_exception(e); } #ifndef BOOST_NO_TYPEID catch( std::bad_cast & e ) { return exception_detail::current_exception_std_exception(e); } catch( std::bad_typeid & e ) { return exception_detail::current_exception_std_exception(e); } #endif catch( std::bad_exception & e ) { return exception_detail::current_exception_std_exception(e); } catch( std::exception & e ) { return exception_detail::current_exception_unknown_std_exception(e); } catch( riakboost::exception & e ) { return exception_detail::current_exception_unknown_boost_exception(e); } catch( ... ) { return exception_detail::current_exception_unknown_exception(); } } } }
inline exception_ptr current_exception_unknown_boost_exception( boost::exception const & e ) { return exception_ptr(exception_detail::make_clone(unknown_exception(e))); }
inline exception_ptr current_exception_unknown_exception() { return exception_ptr(exception_detail::make_clone(unknown_exception())); }
exception_ptr result::make_no_result_error() { static remote_error e(remote_error::no_result, "no result for one way call"); return exception_ptr(&e, null_deleter()); }
inline exception_ptr copy_exception( T&& e ) { try { throw e; } catch (...) { return current_exception(); } return exception_ptr(); }