From 5d9a5734589b1cbd3de7be1f30c34f8aeddc43f8 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sun, 15 Oct 2017 22:00:22 -0700 Subject: [PATCH] ircd::m: Update error.h with bad signature and json::strung changes. --- include/ircd/m/error.h | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/include/ircd/m/error.h b/include/ircd/m/error.h index 56bfb02cf..e61f525a3 100644 --- a/include/ircd/m/error.h +++ b/include/ircd/m/error.h @@ -70,6 +70,7 @@ namespace ircd::m IRCD_M_EXCEPTION(error, BAD_REQUEST, http::BAD_REQUEST); IRCD_M_EXCEPTION(error, BAD_JSON, http::BAD_REQUEST); IRCD_M_EXCEPTION(error, NOT_FOUND, http::NOT_FOUND); + IRCD_M_EXCEPTION(error, BAD_SIGNATURE, http::UNAUTHORIZED); } inline @@ -85,13 +86,13 @@ ircd::m::error::error(const http::code &c) inline ircd::m::error::error(const http::code &c, const json::members &members) -:http::error{c, json::string(members)} +:http::error{c, json::strung(members)} {} inline ircd::m::error::error(const http::code &c, const json::iov &iov) -:http::error{c, json::string(iov)} +:http::error{c, json::strung(iov)} {} inline @@ -116,17 +117,17 @@ ircd::m::error::error(const http::code &status, args&&... a) :http::error { - status, [&]() -> std::string + status, [&]() -> json::strung { - char estr[512]; const auto estr_len + char estr[512]; const auto len { - fmt::snprintf{estr, sizeof(estr), fmt, std::forward(a)...} + fmt::sprintf{estr, fmt, std::forward(a)...} }; - return json::string(json::members + return json::members { - { "errcode", errcode }, - { "error", string_view(estr, estr_len) } - }); + { "errcode", errcode }, + { "error", string_view{estr, size_t(len)} } + }; }() }{}