Skip to content

Commit

Permalink
Exception during completion handler is now caught and used as complet…
Browse files Browse the repository at this point in the history
…ion() failure
  • Loading branch information
tm604 committed Dec 3, 2015
1 parent f78b8f1 commit 880c480
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion include/net/asio/http/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,15 @@ class client {
/* Our response has either been delivered, or we had a failure.
* Delegate to existing handlers first.
*/
auto v = self->on_completion(f, res, retry);
bool v;
try {
/* Raising an exception in the completion handler means we should pass that immediately to the completion() status */
v = self->on_completion(f, res, retry);
} catch(const std::exception &e) {
res->completion()->fail(e);
return;
}

if(!v) {
/* Something didn't like the response and wants us to retry */
res->reset();
Expand Down

0 comments on commit 880c480

Please sign in to comment.