From 83edde639fe2e1fc40ff4694ee0af5481b8e25a1 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Thu, 30 Aug 2018 10:58:32 -0700 Subject: [PATCH] ircd::http: Improve query::string::at() error message to show key name. --- ircd/http.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ircd/http.cc b/ircd/http.cc index 6045ae715..19a0c7899 100644 --- a/ircd/http.cc +++ b/ircd/http.cc @@ -523,7 +523,18 @@ const { const auto ret(operator[](key)); if(ret.empty()) - throw std::out_of_range{"Failed to find value for required query string key"}; + { + thread_local char buf[1024]; + const string_view msg{fmt::sprintf + { + buf, "Failed to find value for required query string key '%s'", key + }}; + + throw std::out_of_range + { + msg.c_str() // fmt::sprintf() will null terminate msg + }; + } return ret; }