Make associative container out-of-range exception provide missing key
Summary: When the key is missing, the standard associative containers throw an exception like `unordered_map::at: key not found`. That's nice, but it would be even better if we would actually know what key is missing. This is not an issue when one is accessing the container directly, but when that access happens several levels deep, such as here within folly formatting logic, we have no way of knowing what key was missing. This poses some difficulties in presenting error to the user. This change makes folly format throw a subclass of `std::out_of_range` exception on a missing key when a string keyed associative container is used for providing parameters. That subclass stores the actual key used so it can be accessed in the exception handler. Existing callers can still catch `std::out_of_range` so they should be unaffected by this change. Reviewed By: ot, yfeldblum Differential Revision: D6202184 fbshipit-source-id: b8a6740aaccc5d8914ad7d099c8b901427f00083
Showing
Please register or sign in to comment