userver: userver/server/handlers/legacy_json_error_builder.hpp Source File
Loading...
Searching...
No Matches
legacy_json_error_builder.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/server/handlers/legacy_json_error_builder.hpp
4/// @brief @copybrief server::handlers::LegacyJsonErrorBuilder
5
6#include <userver/formats/json/value.hpp>
7#include <userver/http/content_type.hpp>
8
9#include <userver/server/handlers/exceptions.hpp>
10#include <userver/server/http/http_status.hpp>
11
12USERVER_NAMESPACE_BEGIN
13
14namespace server::handlers {
15
16/// Legacy JSON error message builder that returns "code" as an integer.
17/// Consider using JsonErrorBuilder instead
19public:
20 static constexpr bool kIsExternalBodyFormatted = true;
21
22 explicit LegacyJsonErrorBuilder(const CustomHandlerException& ex);
23
24 LegacyJsonErrorBuilder(http::HttpStatus status, std::string internal_message, std::string external_error_body);
25
26 LegacyJsonErrorBuilder(
27 http::HttpStatus status,
28 std::string internal_message,
29 std::string external_error_body,
30 const formats::json::Value& details
31 );
32
33 const std::string& GetInternalMessage() const { return internal_message_; };
34
35 const std::string& GetExternalBody() const { return json_error_body_; }
36
37 static const USERVER_NAMESPACE::http::ContentType& GetContentType() {
38 return USERVER_NAMESPACE::http::content_type::kApplicationJson;
39 }
40
41private:
42 std::string internal_message_;
43 std::string json_error_body_;
44};
45
46} // namespace server::handlers
47
48USERVER_NAMESPACE_END