rippled
Loading...
Searching...
No Matches
token_errors.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2022 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#ifndef RIPPLE_PROTOCOL_TOKEN_ERRORS_H_INCLUDED
21#define RIPPLE_PROTOCOL_TOKEN_ERRORS_H_INCLUDED
22
23#include <system_error>
24
25namespace ripple {
38}
39
40namespace std {
41template <>
42struct is_error_code_enum<ripple::TokenCodecErrc> : true_type
43{
44};
45} // namespace std
46
47namespace ripple {
48namespace detail {
50{
51public:
52 // Return a short descriptive name for the category
53 virtual char const*
54 name() const noexcept override final
55 {
56 return "TokenCodecError";
57 }
58 // Return what each enum means in text
59 virtual std::string
60 message(int c) const override final
61 {
62 switch (static_cast<TokenCodecErrc>(c))
63 {
65 return "conversion successful";
67 return "input too large";
69 return "input too small";
71 return "bad base 58 character";
73 return "output too small";
75 return "mismatched token type";
77 return "mismatched checksum";
79 return "invalid encoding char";
81 return "unknown";
82 default:
83 return "unknown";
84 }
85 }
86};
87} // namespace detail
88
95
96inline std::error_code
98{
99 return {static_cast<int>(e), TokenCodecErrcCategory()};
100}
101} // namespace ripple
102#endif // TOKEN_ERRORS_H_
virtual char const * name() const noexcept override final
virtual std::string message(int c) const override final
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
std::error_code make_error_code(ripple::TokenCodecErrc e)
ripple::detail::TokenCodecErrcCategory const & TokenCodecErrcCategory()
STL namespace.