Добавлены структуры исключений

This commit is contained in:
Антон
2025-09-29 08:48:42 +03:00
parent 7d19dcb69a
commit 87f1e4a735
2 changed files with 30 additions and 11 deletions
@@ -8,6 +8,7 @@
#include "IExecutor.h"
#include "../DAO/IUserDAO.h"
#include "../exceptions/exception400_bad_request.h"
namespace uad
{
@@ -37,24 +38,17 @@ public:
value req_json;
value response_body;
response_body.emplace_object();
try
{
req_json = json::parse(body);
}
catch (const system::system_error& err)
{
http::response<ResponseType> res{http::status::bad_request, req.version()};
response_body.as_object().emplace("Result", "cannot deserialize json");
res.body() = serialize(response_body);
res.set(http::field::content_type, "application/json");
res.content_length(res.body().size());
return res;
throw exception400_bad_request("cannot deserialize json");
}
response_body.emplace_object();
const std::string login = req_json.as_object().at("login").as_string().c_str();
const std::string password = req_json.as_object().at("password").as_string().c_str();