Registration переведен на систему исключений вместо возврата

This commit is contained in:
Антон
2025-09-29 18:13:29 +03:00
parent 0ef4c7e46c
commit 0042b7e6bc
2 changed files with 36 additions and 26 deletions
+28
View File
@@ -108,6 +108,34 @@ public:
res.set(boost::beast::http::field::content_type, "application/json");
res.content_length(res.body().size());
return send(std::move(res));
}
catch (const exception409_conflict& e)
{
boost::beast::http::response<ResponseType> res{boost::beast::http::status::conflict, req.version()};
boost::json::value response_body;
response_body.emplace_object();
response_body.as_object().emplace("Result", e.what());
res.body() = serialize(response_body);
res.set(boost::beast::http::field::content_type, "application/json");
res.content_length(res.body().size());
return send(std::move(res));
}
catch (const exception422_unprocessable_entity& e)
{
boost::beast::http::response<ResponseType> res{boost::beast::http::status::unprocessable_entity, req.version()};
boost::json::value response_body;
response_body.emplace_object();
response_body.as_object().emplace("Result", e.what());
res.body() = serialize(response_body);
res.set(boost::beast::http::field::content_type, "application/json");
res.content_length(res.body().size());
return send(std::move(res));
}
}