I'm using the asio networking library. I'm seeing a very strange behaviour where the debugger tells me that the call to std::map::at() throws an out_of_range exception, however I have catch block to catch precisely that type of exception!
The map in question is this:
/*Both of these maps are global variables in the namespace cloud*/
map<string, weak_ptr<session> > cloud::services;
map<string, vector<weak_ptr<session> > > cloud::subscribed; //this one
And the code that's throwing the exception is this:
void session::subscribirse(std::string a_which)
{
try
{
//We obtain a reference to the group of sockets subscribed to this service name
vector<weak_ptr<session>>& grupo = cloud::subscribed.at(a_which); //HERE
grupo.emplace_back(shared_from_this() );
}
catch(out_of_range& e) //The group didn't exist (no-one had subscribed to it yet)
{
vector<weak_ptr<session>> new_group;
new_group.emplace_back(shared_from_this());
cloud::subscribed.emplace(make_pair(a_which, new_group));
}
catch(...)
{
cout << "unexpected exception during subscribe\n";
}
subscriptions_.emplace_back(a_which);
consumed_ = true;
}
Could the catch-block be rethrowing and the debugger not being capable of detecting that? (I really don't think so).
Sorry if question is not clear, I've spent the last 6 hours and I'm feeling desperate.