Clio
develop
The XRP Ledger API server.
Theme:
Default
Round
Robot
Toggle main menu visibility
Loading...
Searching...
No Matches
ErrorHandling.hpp
1
#pragma once
2
3
#include "
rpc/Errors.hpp
"
4
#include "web/ng/Request.hpp"
5
#include "web/ng/Response.hpp"
6
7
#include <boost/beast/http/status.hpp>
8
#include <boost/json/object.hpp>
9
#include <boost/json/serialize.hpp>
10
#include <fmt/format.h>
11
#include <xrpl/protocol/ErrorCodes.h>
12
#include <xrpl/protocol/jss.h>
13
14
#include <functional>
15
#include <optional>
16
17
namespace
web::ng::impl {
18
22
class
ErrorHelper
{
23
std::reference_wrapper<Request const> rawRequest_;
24
std::optional<boost::json::object> request_;
25
26
public
:
33
ErrorHelper
(
34
Request
const
& rawRequest,
35
std::optional<boost::json::object> request = std::nullopt
36
);
37
44
[[nodiscard]]
Response
45
makeError
(rpc::Status
const
& err)
const
;
46
52
[[nodiscard]]
Response
53
makeInternalError
()
const
;
54
60
[[nodiscard]]
Response
61
makeNotReadyError
()
const
;
62
68
[[nodiscard]]
Response
69
makeTooBusyError
()
const
;
70
76
[[nodiscard]]
Response
77
makeJsonParsingError
()
const
;
78
85
[[nodiscard]] boost::json::object
86
composeError
(rpc::Status
const
& error)
const
;
87
94
[[nodiscard]] boost::json::object
95
composeError
(rpc::XrpldError error)
const
;
96
};
97
98
}
// namespace web::ng::impl
Errors.hpp
web::ng::Request
Represents an HTTP or WebSocket request.
Definition
Request.hpp:18
web::ng::Response
Represents an HTTP or Websocket response.
Definition
Response.hpp:21
web::ng::impl::ErrorHelper::makeTooBusyError
Response makeTooBusyError() const
Make a response for when the server is too busy.
Definition
ErrorHandling.cpp:125
web::ng::impl::ErrorHelper::composeError
boost::json::object composeError(rpc::Status const &error) const
Compose an error into json object from a status.
Definition
ErrorHandling.cpp:155
web::ng::impl::ErrorHelper::makeJsonParsingError
Response makeJsonParsingError() const
Make a response when json parsing fails.
Definition
ErrorHandling.cpp:141
web::ng::impl::ErrorHelper::makeError
Response makeError(rpc::Status const &err) const
Make an error response from a status.
Definition
ErrorHandling.cpp:63
web::ng::impl::ErrorHelper::makeNotReadyError
Response makeNotReadyError() const
Make a response for when the server is not ready.
Definition
ErrorHandling.cpp:119
web::ng::impl::ErrorHelper::makeInternalError
Response makeInternalError() const
Make an internal error response.
Definition
ErrorHandling.cpp:111
web::ng::impl::ErrorHelper::ErrorHelper
ErrorHelper(Request const &rawRequest, std::optional< boost::json::object > request=std::nullopt)
Construct a new Error Helper object.
Definition
ErrorHandling.cpp:57
src
web
ng
impl
ErrorHandling.hpp
Generated by
1.17.0