Skip to content

Commit

Permalink
Route most ERROR messages not just CALL to the correct promises/futur…
Browse files Browse the repository at this point in the history
…es. If they can't be passed to a sensible place at least pass the error message inside the thrown exception.
  • Loading branch information
Bigpet committed Nov 3, 2016
1 parent 5d081f7 commit f85beb1
Showing 1 changed file with 58 additions and 4 deletions.
62 changes: 58 additions & 4 deletions autobahn/wamp_session.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -936,14 +936,68 @@ inline void wamp_session::process_error(wamp_message&& message)
call_itr->second->result().set_exception(boost::copy_exception(std::runtime_error(error)));
m_calls.erase(call_itr);
} else {
throw protocol_error("bogus ERROR message for non-pending CALL request ID");
throw protocol_error("bogus ERROR message for non-pending CALL request ID: " + error);
}
}
break;
case message_type::REGISTER:
{
auto reg_itr = m_register_requests.find(request_id);
if (reg_itr != m_register_requests.end())
{
reg_itr->second->response().set_exception(boost::copy_exception(std::runtime_error(error)));
m_register_requests.erase(reg_itr);
} else {
throw protocol_error("bogus ERROR message for non-pending REGISTER request ID: " + error);
}
}
break;
case message_type::UNREGISTER:
{
auto unreg_itr = m_unregister_requests.find(request_id);
if (unreg_itr != m_unregister_requests.end())
{
unreg_itr->second->response().set_exception(boost::copy_exception(std::runtime_error(error)));
m_unregister_requests.erase(unreg_itr);
} else {
throw protocol_error("bogus ERROR message for non-pending UNREGISTER request ID: " + error);
}
}
break;
case message_type::PUBLISH:
{
//TODO: there's currently no way to get to the future returned by the publish function
// but there needs to be something more sensibly then just propagating the error to the
// function running the io_service
throw protocol_error("Received ERROR for a PUBLISH request: " + error);
}
break;
case message_type::SUBSCRIBE:
{
auto sub_itr = m_subscribe_requests.find(request_id);
if (sub_itr != m_subscribe_requests.end())
{
sub_itr->second->response().set_exception(boost::copy_exception(std::runtime_error(error)));
m_subscribe_requests.erase(sub_itr);
} else {
throw protocol_error("bogus ERROR message for non-pending SUBSCRIBE request ID: " + error);
}
}
break;
case message_type::UNSUBSCRIBE:
{
auto unsub_itr = m_unsubscribe_requests.find(request_id);
if (unsub_itr != m_unsubscribe_requests.end())
{
unsub_itr->second->response().set_exception(boost::copy_exception(std::runtime_error(error)));
m_unsubscribe_requests.erase(unsub_itr);
} else {
throw protocol_error("bogus ERROR message for non-pending UNSUBSCRIBE request ID: " + error);
}
}
break;

// FIXME: handle other error messages
default:
throw protocol_error("unhandled ERROR message");
throw protocol_error("unhandled ERROR message: " + error);
break;
}
}
Expand Down

0 comments on commit f85beb1

Please sign in to comment.