mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-19 11:15:50 +00:00
fix: Print out error details of web context (#2351)
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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. */
|
||||
|
||||
Reference in New Issue
Block a user