generated from Sithas/conan_template
Добавлены структуры исключений
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
#include <mysqlx/xdevapi.h>
|
||||
#include <mysqlx/common/api.h>
|
||||
|
||||
#include "IExecutor.h"
|
||||
#include "IController.h"
|
||||
#include "Controller.h"
|
||||
@@ -7,6 +10,9 @@
|
||||
#include "../DAO/IUserDAO.h"
|
||||
#include "../DAO/IAuthDAO.h"
|
||||
#include "./../helpers/helpers.h"
|
||||
#include "./../exceptions/exception400_bad_request.h"
|
||||
#include "./../exceptions/exception409_conflict.h"
|
||||
#include "./../exceptions/exception422_unprocessable_entity.h"
|
||||
|
||||
namespace uad
|
||||
{
|
||||
@@ -84,7 +90,26 @@ public:
|
||||
{
|
||||
IRouteExecutor& executor = *maybe_executor_ptr.value();
|
||||
|
||||
return send(executor(std::move(req)));
|
||||
try
|
||||
{
|
||||
boost::beast::http::response<ResponseType> res = executor(std::move(req));
|
||||
|
||||
return send(std::move(res));
|
||||
}
|
||||
catch (const exception400_bad_request& e)
|
||||
{
|
||||
boost::beast::http::response<ResponseType> res{boost::beast::http::status::bad_request, 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user