rippled
Loading...
Searching...
No Matches
error.cpp
1#include <xrpld/conditions/detail/error.h>
2
3#include <xrpl/basics/safe_cast.h>
4
5#include <string>
6
7namespace ripple {
8namespace cryptoconditions {
9namespace detail {
10
12{
13public:
14 explicit cryptoconditions_error_category() = default;
15
16 char const*
17 name() const noexcept override
18 {
19 return "cryptoconditions";
20 }
21
23 message(int ev) const override
24 {
25 switch (safe_cast<error>(ev))
26 {
28 return "Specification: Requested type not supported.";
29
31 return "Specification: Requested subtype not supported.";
32
34 return "Specification: Requested type not recognized.";
35
37 return "Specification: Requested subtypes not recognized.";
38
40 return "Specification: Incorrect fingerprint size.";
41
43 return "Specification: Incorrect encoding.";
44
46 return "Bad buffer: contains trailing garbage.";
47
49 return "Bad buffer: no data.";
50
52 return "Bad buffer: overfull.";
53
55 return "Bad buffer: underfull.";
56
58 return "Malformed DER encoding.";
59
61 return "Malformed DER encoding: Unexpected tag.";
62
64 return "Malformed DER encoding: Short preamble.";
65
66 case error::long_tag:
67 return "Implementation limit: Overlong tag.";
68
70 return "Implementation limit: Large payload.";
71
73 return "Implementation limit: Specified preimage is too long.";
74
75 case error::generic:
76 default:
77 return "generic error";
78 }
79 }
80
82 default_error_condition(int ev) const noexcept override
83 {
84 return std::error_condition{ev, *this};
85 }
86
87 bool
88 equivalent(int ev, std::error_condition const& condition)
89 const noexcept override
90 {
91 return &condition.category() == this && condition.value() == ev;
92 }
93
94 bool
95 equivalent(std::error_code const& error, int ev) const noexcept override
96 {
97 return &error.category() == this && error.value() == ev;
98 }
99};
100
101inline std::error_category const&
103{
104 static cryptoconditions_error_category const cat{};
105 return cat;
106}
107
108} // namespace detail
109
112{
113 return std::error_code{
114 safe_cast<std::underlying_type<error>::type>(ev),
116}
117
118} // namespace cryptoconditions
119} // namespace ripple
bool equivalent(int ev, std::error_condition const &condition) const noexcept override
Definition error.cpp:88
bool equivalent(std::error_code const &error, int ev) const noexcept override
Definition error.cpp:95
std::error_condition default_error_condition(int ev) const noexcept override
Definition error.cpp:82
std::error_category const & get_cryptoconditions_error_category()
Definition error.cpp:102
std::error_code make_error_code(error ev)
Definition error.cpp:111
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6