fix: Print out error details of web context (#2351)

This commit is contained in:
emrearıyürek
2025-09-22 14:45:04 +02:00
committed by GitHub
parent 245a808e4b
commit d2de240389
3 changed files with 112 additions and 2 deletions

View File

@@ -39,6 +39,39 @@ using namespace std;
namespace rpc {
std::ostream&
operator<<(std::ostream& stream, Status const& status)
{
std::visit(
util::OverloadSet{
[&stream, &status](RippledError err) {
stream << "Code: " << static_cast<std::underlying_type_t<RippledError>>(err);
if (!status.error.empty())
stream << ", Error: " << status.error;
if (!status.message.empty())
stream << ", Message: " << status.message;
else
stream << ", Message: " << ripple::RPC::get_error_info(err).message;
},
[&stream, &status](ClioError err) {
stream << "Code: " << static_cast<std::underlying_type_t<ClioError>>(err);
if (!status.error.empty())
stream << ", Error: " << status.error;
if (!status.message.empty())
stream << ", Message: " << status.message;
else
stream << ", Message: " << getErrorInfo(err).message;
}
},
status.code
);
if (status.extraInfo.has_value())
stream << ", Extra Info: " << *status.extraInfo;
return stream;
}
WarningInfo const&
getWarningInfo(WarningCode code)
{

View File

@@ -182,6 +182,16 @@ struct Status {
return false;
}
/**
* @brief Custom output stream for Status
*
* @param stream The output stream
* @param status The Status
* @return The same ostream we were given
*/
friend std::ostream&
operator<<(std::ostream& stream, Status const& status);
};
/** @brief Warning codes that can be returned by clio. */