From 8adc4c1e3c4444a09d58ce14413e57bb8afb9ca8 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Sun, 31 May 2015 11:53:25 -0700 Subject: [PATCH] Add rpcErrorString function --- src/ripple/protocol/ErrorCodes.h | 5 ++++- src/ripple/protocol/impl/ErrorCodes.cpp | 11 ++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/ripple/protocol/ErrorCodes.h b/src/ripple/protocol/ErrorCodes.h index d60f070609..e071e907fd 100644 --- a/src/ripple/protocol/ErrorCodes.h +++ b/src/ripple/protocol/ErrorCodes.h @@ -260,7 +260,10 @@ inline Json::Value expected_field_error ( /** Returns `true` if the json contains an rpc error specification. */ bool contains_error (Json::Value const& json); -} +} // RPC + +/** Returns a single string with the contents of an RPC error. */ +std::string rpcErrorString(Json::Value const& jv); } diff --git a/src/ripple/protocol/impl/ErrorCodes.cpp b/src/ripple/protocol/impl/ErrorCodes.cpp index 4b557ea96c..71eadd6c7b 100644 --- a/src/ripple/protocol/impl/ErrorCodes.cpp +++ b/src/ripple/protocol/impl/ErrorCodes.cpp @@ -170,5 +170,14 @@ bool contains_error (Json::Value const& json) return false; } +} // RPC + +std::string rpcErrorString(Json::Value const& jv) +{ + assert(RPC::contains_error(jv)); + return jv[jss::error].asString() + + jv[jss::error_message].asString(); } -} + +} // ripple +