There was an uncaught out_of_range exception, that can be thrown
by unordered_map::at() method. It will be better to use a more
detailed exception here. It will also fit into design of other
methods from InMemoryStorageBackend.
Change-Id: Ib70f10c79358b08f3b2a792143a1498050cc677a
PolicyBucket InMemoryStorageBackend::searchBucket(const PolicyBucketId &bucketId,
const PolicyKey &key) {
- const auto &bucket = this->buckets().at(bucketId);
- return bucket.filtered(key);
+ try {
+ const auto &bucket = this->buckets().at(bucketId);
+ return bucket.filtered(key);
+ } catch (const std::out_of_range &) {
+ throw BucketNotExistsException(bucketId);
+ }
}
void InMemoryStorageBackend::insertPolicy(const PolicyBucketId &bucketId, PolicyPtr policy) {