0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-11 14:38:57 +02:00

ircd::server: Improve some exception messages conveyed back to promise.

This commit is contained in:
Jason Volk 2018-01-17 01:05:31 -08:00
parent 862fb1ebcd
commit 7f9f970b5b
2 changed files with 16 additions and 12 deletions

View file

@ -35,14 +35,14 @@ struct ircd::server::node
void resolve(const hostport &);
void disperse_uncommitted(link &);
void cancel_committed(link &, const std::exception &);
void cancel_committed(link &, std::exception_ptr);
void disperse(link &);
void del(link &);
void handle_link_done(link &);
void handle_tag_done(link &, tag &) noexcept;
void handle_error(link &, const boost::system::system_error &);
void handle_error(link &, const std::exception &);
void handle_error(link &, std::exception_ptr);
void handle_close(link &, std::exception_ptr);
void handle_open(link &, std::exception_ptr);

View file

@ -466,15 +466,19 @@ catch(const std::exception &e)
void
ircd::server::node::handle_error(link &link,
const std::exception &e)
std::exception_ptr eptr)
try
{
cancel_committed(link, eptr);
link.close(net::dc::RST);
std::rethrow_exception(eptr);
}
catch(const std::exception &e)
{
log.error("node(%p) link(%p): %s",
this,
&link,
e.what());
cancel_committed(link, e);
link.close(net::dc::RST);
}
void
@ -563,17 +567,17 @@ void
ircd::server::node::disperse(link &link)
{
disperse_uncommitted(link);
cancel_committed(link, canceled
cancel_committed(link, std::make_exception_ptr(canceled
{
"Request was partially completed when fatal error occurred"
});
}));
assert(link.queue.empty());
}
void
ircd::server::node::cancel_committed(link &link,
const std::exception &e)
std::exception_ptr eptr)
{
auto &queue(link.queue);
@ -587,13 +591,13 @@ ircd::server::node::cancel_committed(link &link,
})
};
std::for_each(begin(queue), it, [this, &e](auto &tag)
std::for_each(begin(queue), it, [this, &eptr](auto &tag)
{
if(!tag.request)
return;
assert(tag.write_completed());
tag.set_exception(e);
tag.set_exception(eptr);
disassociate(*tag.request, tag);
});
@ -1140,7 +1144,7 @@ catch(const std::exception &e)
{
if(node)
{
node->handle_error(*this, e);
node->handle_error(*this, std::make_exception_ptr(std::current_exception()));
return;
}