Clio
develop
The XRP Ledger API server.
Theme:
Default
Round
Robot
Toggle main menu visibility
Loading...
Searching...
No Matches
Error.hpp
1
#pragma once
2
3
#include <cassandra.h>
4
5
#include <cstdint>
6
#include <ostream>
7
#include <string>
8
#include <utility>
9
10
namespace
data::cassandra
{
11
15
class
CassandraError {
16
std::string message_;
17
uint32_t code_{};
18
19
public
:
20
// default constructible required by Expected
21
CassandraError() =
default
;
22
29
CassandraError
(std::string
message
, uint32_t
code
) : message_{std::move(
message
)}, code_{
code
}
30
{
31
}
32
34
template
<
typename
T>
35
friend
std::string
36
operator+(T
const
& lhs,
CassandraError
const
& rhs)
37
requires
std::is_convertible_v<T, std::string>
38
{
39
return
lhs + rhs.message();
40
}
41
42
template
<
typename
T>
43
friend
bool
44
operator==(T
const
& lhs, CassandraError
const
& rhs)
45
requires
std::is_convertible_v<T, std::string>
46
{
47
return
lhs == rhs.message();
48
}
49
50
template
<std::
int
egral T>
51
friend
bool
52
operator==(T
const
& lhs, CassandraError
const
& rhs)
53
{
54
return
lhs == rhs.code();
55
}
56
57
friend
std::ostream&
58
operator<<
(std::ostream& os, CassandraError
const
& err)
59
{
60
os << err.message();
61
return
os;
62
}
64
68
[[nodiscard]] std::string
69
message
()
const
70
{
71
return
message_;
72
}
73
77
[[nodiscard]] uint32_t
78
code
()
const
79
{
80
return
code_;
81
}
82
86
[[nodiscard]]
bool
87
isInvalidQuery
()
const
88
{
89
return
code_ == CASS_ERROR_SERVER_INVALID_QUERY;
90
}
91
};
92
93
}
// namespace data::cassandra
data::cassandra::CassandraError
A simple container for both error message and error code.
Definition
Error.hpp:15
data::cassandra::CassandraError::CassandraError
CassandraError(std::string message, uint32_t code)
Construct a new CassandraError object.
Definition
Error.hpp:29
data::cassandra::CassandraError::isInvalidQuery
bool isInvalidQuery() const
Definition
Error.hpp:87
data::cassandra::CassandraError::code
uint32_t code() const
Definition
Error.hpp:78
data::cassandra::CassandraError::message
std::string message() const
Definition
Error.hpp:69
data::cassandra
This namespace implements a wrapper for the Cassandra C++ driver.
Definition
CassandraBackendFamily.hpp:47
rpc::operator<<
std::ostream & operator<<(std::ostream &stream, Status const &status)
Stream a Status in human readable form.
Definition
Errors.cpp:51
src
data
cassandra
Error.hpp
Generated by
1.17.0