diff --git a/src/clientget.cpp b/src/clientget.cpp index 834756d..c57da2f 100644 --- a/src/clientget.cpp +++ b/src/clientget.cpp @@ -590,10 +590,15 @@ std::shared_ptr gpr_setup(const std::shared_ptr& context context->tcp_loop.dispatch([internal, context, name, server]() { // on worker - internal->chan = Channel::build(context, name, server); + try { + internal->chan = Channel::build(context, name, server); - internal->chan->pending.push_back(internal); - internal->chan->createOperations(); + internal->chan->pending.push_back(internal); + internal->chan->createOperations(); + }catch(...){ + internal->result = Result(std::current_exception()); + internal->notify(); + } }); return external; diff --git a/src/clientintrospect.cpp b/src/clientintrospect.cpp index 47caf1c..590073c 100644 --- a/src/clientintrospect.cpp +++ b/src/clientintrospect.cpp @@ -218,10 +218,22 @@ std::shared_ptr GetBuilder::_exec_info() context->tcp_loop.dispatch([op, context, name, server]() { // on worker - op->chan = Channel::build(context, name, server); + try { + op->chan = Channel::build(context, name, server); - op->chan->pending.push_back(op); - op->chan->createOperations(); + op->chan->pending.push_back(op); + op->chan->createOperations(); + }catch(...){ + try { + Result res(std::current_exception()); + if(op->done) + op->done(std::move(res)); + else + res(); // rethrow to log... + }catch(std::exception& e){ + log_exc_printf(setup, "Unhandled exception %s in Info result() callback: %s\n", typeid (e).name(), e.what()); + } + } }); return external; diff --git a/src/clientmon.cpp b/src/clientmon.cpp index 86cc39d..bdcd4e2 100644 --- a/src/clientmon.cpp +++ b/src/clientmon.cpp @@ -857,10 +857,18 @@ std::shared_ptr MonitorBuilder::exec() context->tcp_loop.dispatch([op, context, server]() { // on worker - op->chan = Channel::build(context, op->channelName, server); + try { + op->chan = Channel::build(context, op->channelName, server); - op->chan->pending.push_back(op); - op->chan->createOperations(); + op->chan->pending.push_back(op); + op->chan->createOperations(); + }catch(...){ + // nothing else has happened, so the queue will be empty + assert(op->queue.empty()); + op->queue.emplace_back(); + op->queue.back().exc = std::current_exception(); + op->doNotify(); + } }); return external;