Is there a way to know which key was involved when a call like the following fails ?
boost::program_options::variables_map vm;
...
int foo_bar = vm["some_key"].as<int>();
If the key is missing from the map, or is not convertible to int, I get a rather uninformative bad_any_cast, and I can't know any of the following:
- the key involved
- the stored value, or even if it's there.
- the types involved
I can't find of any solution that doesn't involve either modifying the boost header or wrapping every call to the above in a try..catch block. I think it's a common issue, so maybe someone else knows a better approach.