Files
rippled/include/xrpl/protocol/detail/token_errors.h
Bart 1d42c4f6de refactor: Remove unnecessary copyright notices already covered by LICENSE.md (#5929)
Per XLS-0095, we are taking steps to rename ripple(d) to xrpl(d).

This change specifically removes all copyright notices referencing Ripple, XRPLF, and certain affiliated contributors upon mutual agreement, so the notice in the LICENSE.md file applies throughout. Copyright notices referencing external contributions remain as-is. Duplicate verbiage is also removed.
2025-11-04 08:33:42 +00:00

84 lines
2.1 KiB
C++

#ifndef XRPL_PROTOCOL_TOKEN_ERRORS_H_INCLUDED
#define XRPL_PROTOCOL_TOKEN_ERRORS_H_INCLUDED
#include <system_error>
namespace ripple {
enum class TokenCodecErrc {
success = 0,
inputTooLarge,
inputTooSmall,
badB58Character,
outputTooSmall,
mismatchedTokenType,
mismatchedChecksum,
invalidEncodingChar,
overflowAdd,
unknown,
};
}
namespace std {
template <>
struct is_error_code_enum<ripple::TokenCodecErrc> : true_type
{
};
} // namespace std
namespace ripple {
namespace detail {
class TokenCodecErrcCategory : public std::error_category
{
public:
// Return a short descriptive name for the category
virtual char const*
name() const noexcept override final
{
return "TokenCodecError";
}
// Return what each enum means in text
virtual std::string
message(int c) const override final
{
switch (static_cast<TokenCodecErrc>(c))
{
case TokenCodecErrc::success:
return "conversion successful";
case TokenCodecErrc::inputTooLarge:
return "input too large";
case TokenCodecErrc::inputTooSmall:
return "input too small";
case TokenCodecErrc::badB58Character:
return "bad base 58 character";
case TokenCodecErrc::outputTooSmall:
return "output too small";
case TokenCodecErrc::mismatchedTokenType:
return "mismatched token type";
case TokenCodecErrc::mismatchedChecksum:
return "mismatched checksum";
case TokenCodecErrc::invalidEncodingChar:
return "invalid encoding char";
case TokenCodecErrc::unknown:
return "unknown";
default:
return "unknown";
}
}
};
} // namespace detail
inline ripple::detail::TokenCodecErrcCategory const&
TokenCodecErrcCategory()
{
static ripple::detail::TokenCodecErrcCategory c;
return c;
}
inline std::error_code
make_error_code(ripple::TokenCodecErrc e)
{
return {static_cast<int>(e), TokenCodecErrcCategory()};
}
} // namespace ripple
#endif // TOKEN_ERRORS_H_