mirror of
https://github.com/matrix-construct/construct
synced 2024-12-28 00:14:07 +01:00
ircd::json: Proper throw when iov::at() key is not found.
This commit is contained in:
parent
0c838448c2
commit
89ccdaa510
1 changed files with 13 additions and 4 deletions
13
ircd/json.cc
13
ircd/json.cc
|
@ -449,11 +449,20 @@ const ircd::json::value &
|
||||||
ircd::json::iov::at(const string_view &key)
|
ircd::json::iov::at(const string_view &key)
|
||||||
const
|
const
|
||||||
{
|
{
|
||||||
const auto it(std::find_if(std::begin(*this), std::end(*this), [&key]
|
const auto it
|
||||||
|
{
|
||||||
|
std::find_if(std::begin(*this), std::end(*this), [&key]
|
||||||
(const auto &member)
|
(const auto &member)
|
||||||
{
|
{
|
||||||
return string_view{member.first} == key;
|
return string_view{member.first} == key;
|
||||||
}));
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
if(it == std::end(*this))
|
||||||
|
throw not_found
|
||||||
|
{
|
||||||
|
"key '%s' not found", key
|
||||||
|
};
|
||||||
|
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue