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