mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Make three ErrorCode functions generic.
This commit is contained in:
committed by
Vinnie Falco
parent
f12b15d22b
commit
d9c7db51af
@@ -34,9 +34,9 @@ namespace jss {
|
||||
// TODO Move the string not part of the JSON-RPC API into another file
|
||||
JSS ( accepted );
|
||||
JSS ( account );
|
||||
JSS ( accounts );
|
||||
JSS ( account_hash );
|
||||
JSS ( account_index );
|
||||
JSS ( accounts );
|
||||
JSS ( accountState );
|
||||
JSS ( accountTreeHash );
|
||||
JSS ( affected );
|
||||
@@ -70,7 +70,9 @@ JSS ( engine_result );
|
||||
JSS ( engine_result_code );
|
||||
JSS ( engine_result_message );
|
||||
JSS ( error );
|
||||
JSS ( error_code );
|
||||
JSS ( error_exception );
|
||||
JSS ( error_message );
|
||||
JSS ( fee_base );
|
||||
JSS ( fee_ref );
|
||||
JSS ( fetch_pack );
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#ifndef RIPPLE_RPC_ERRORCODES_H_INCLUDED
|
||||
#define RIPPLE_RPC_ERRORCODES_H_INCLUDED
|
||||
|
||||
#include <ripple/protocol/JsonFields.h>
|
||||
#include <ripple/unity/json.h>
|
||||
|
||||
namespace ripple {
|
||||
@@ -139,10 +140,31 @@ ErrorInfo const& get_error_info (error_code_i code);
|
||||
|
||||
/** Add or update the json update to reflect the error code. */
|
||||
/** @{ */
|
||||
void inject_error (error_code_i code, Json::Value& json);
|
||||
inline void inject_error (int code, Json::Value& json)
|
||||
{ inject_error (error_code_i (code), json); }
|
||||
void inject_error (error_code_i code, std::string const& message, Json::Value& json);
|
||||
template <class JsonValue>
|
||||
void inject_error (error_code_i code, JsonValue& json)
|
||||
{
|
||||
ErrorInfo const& info (get_error_info (code));
|
||||
json [jss::error] = info.token;
|
||||
json [jss::error_code] = info.code;
|
||||
json [jss::error_message] = info.message;
|
||||
}
|
||||
|
||||
template <class JsonValue>
|
||||
void inject_error (int code, JsonValue& json)
|
||||
{
|
||||
inject_error (error_code_i (code), json);
|
||||
}
|
||||
|
||||
template <class JsonValue>
|
||||
void inject_error (
|
||||
error_code_i code, std::string const& message, JsonValue& json)
|
||||
{
|
||||
ErrorInfo const& info (get_error_info (code));
|
||||
json [jss::error] = info.token;
|
||||
json [jss::error_code] = info.code;
|
||||
json [jss::error_message] = message;
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
||||
/** Returns a new json object that reflects the error code. */
|
||||
|
||||
@@ -149,22 +149,6 @@ ErrorInfo const& get_error_info (error_code_i code)
|
||||
return category.get (code);
|
||||
}
|
||||
|
||||
void inject_error (error_code_i code, Json::Value& json)
|
||||
{
|
||||
ErrorInfo const& info (get_error_info (code));
|
||||
json ["error"] = info.token;
|
||||
json ["error_code"] = info.code;
|
||||
json ["error_message"] = info.message;
|
||||
}
|
||||
|
||||
void inject_error (error_code_i code, std::string const& message, Json::Value& json)
|
||||
{
|
||||
ErrorInfo const& info (get_error_info (code));
|
||||
json ["error"] = info.token;
|
||||
json ["error_code"] = info.code;
|
||||
json ["error_message"] = message;
|
||||
}
|
||||
|
||||
Json::Value make_error (error_code_i code)
|
||||
{
|
||||
Json::Value json;
|
||||
|
||||
Reference in New Issue
Block a user