From 89ccdaa5104a8e255678a821e5ba50769723996e Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Mon, 22 Jan 2018 14:55:00 -0800 Subject: [PATCH] ircd::json: Proper throw when iov::at() key is not found. --- ircd/json.cc | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/ircd/json.cc b/ircd/json.cc index dbbba2495..d37cf346c 100644 --- a/ircd/json.cc +++ b/ircd/json.cc @@ -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; }