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