void JsonRpcResponse::setError(const Error& error, const json::Value& clientInfo) { // remove result response_.erase(kRpcResult); response_.erase(kRpcAsyncHandle); const boost::system::error_code& ec = error.code(); if ( ec.category() == jsonRpcCategory() ) { setError(ec); } else { // execution error json::Object jsonError ; copyErrorCodeToJsonError(errc::ExecutionError, &jsonError); // populate sub-error field with error details json::Object executionError; executionError["code"] = ec.value(); std::string errorCategoryName = ec.category().name(); executionError["category"] = errorCategoryName; std::string errorMessage = ec.message(); executionError["message"] = errorMessage; jsonError["error"] = executionError; if (!clientInfo.is_null()) { jsonError["client_info"] = clientInfo; } // set error setField(kRpcError, jsonError); } }
void JsonRpcResponse::setError(const boost::system::error_code& ec) { // remove result response_.erase(kRpcResult); response_.erase(kRpcAsyncHandle); // error from error code json::Object error ; copyErrorCodeToJsonError(ec, &error); // sub-error is null error["error"] = json::Value(); // set error setField(kRpcError, error); }
void JsonRpcResponse::setError(const boost::system::error_code& ec, const json::Value& clientInfo) { // remove result response_.erase(kRpcResult); response_.erase(kRpcAsyncHandle); // error from error code json::Object error ; copyErrorCodeToJsonError(ec, &error); // client info if provided if (!clientInfo.is_null()) { error["client_info"] = clientInfo; } // sub-error is null error["error"] = json::Value(); // set error setField(kRpcError, error); }