userver: userver/server/handlers/json_error_builder.hpp Source File
Loading...
Searching...
No Matches
json_error_builder.hpp
Go to the documentation of this file.
1#pragma once
2
5
8
10
11USERVER_NAMESPACE_BEGIN
12
13namespace server::handlers {
14
17class JsonErrorBuilder {
18public:
19 static constexpr bool kIsExternalBodyFormatted = true;
20
21 explicit JsonErrorBuilder(const CustomHandlerException& ex);
22
23 JsonErrorBuilder(
24 std::string_view error_code,
25 std::string internal_message,
26 std::string_view external_error_body,
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