0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-26 15:33:54 +01:00

ircd::json: Proper throw when iov::at() key is not found.

This commit is contained in:
Jason Volk 2018-01-22 14:55:00 -08:00
parent 0c838448c2
commit 89ccdaa510

View file

@ -449,11 +449,20 @@ const ircd::json::value &
ircd::json::iov::at(const string_view &key)
const
{
const auto it(std::find_if(std::begin(*this), std::end(*this), [&key]
(const auto &member)
const auto it
{
return string_view{member.first} == key;
}));
std::find_if(std::begin(*this), std::end(*this), [&key]
(const auto &member)
{
return string_view{member.first} == key;
})
};
if(it == std::end(*this))
throw not_found
{
"key '%s' not found", key
};
return it->second;
}