Browse Source

throw -> BOOST_THROW_EXCEPTION

cl-refactor
Marek Kotewicz 10 years ago
parent
commit
5a69bf5816
  1. 68
      libweb3jsonrpc/WebThreeStubServerBase.cpp

68
libweb3jsonrpc/WebThreeStubServerBase.cpp

@ -314,7 +314,7 @@ string WebThreeStubServerBase::eth_getBalance(string const& _address, string con
} }
catch (...) catch (...)
{ {
throw JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS); BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
} }
return toJS(client()->balanceAt(address, number)); return toJS(client()->balanceAt(address, number));
@ -333,7 +333,7 @@ Json::Value WebThreeStubServerBase::eth_getStorage(string const& _address, strin
} }
catch (...) catch (...)
{ {
throw JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS); BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
} }
//TODO: fix this naming ! //TODO: fix this naming !
@ -354,7 +354,7 @@ string WebThreeStubServerBase::eth_getStorageAt(string const& _address, string c
} }
catch (...) catch (...)
{ {
throw JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS); BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
} }
//TODO: fix this naming ! //TODO: fix this naming !
@ -373,7 +373,7 @@ string WebThreeStubServerBase::eth_getTransactionCount(string const& _address, s
} }
catch (...) catch (...)
{ {
throw JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS); BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
} }
return toJS(client()->countAt(address, number)); return toJS(client()->countAt(address, number));
@ -389,7 +389,7 @@ string WebThreeStubServerBase::eth_getBlockTransactionCountByHash(string const&
} }
catch (...) catch (...)
{ {
throw JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS); BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
} }
return toJS(client()->transactionCount(hash)); return toJS(client()->transactionCount(hash));
@ -406,7 +406,7 @@ string WebThreeStubServerBase::eth_getBlockTransactionCountByNumber(string const
} }
catch (...) catch (...)
{ {
throw JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS); BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
} }
return toJS(client()->transactionCount(client()->hashFromNumber(number))); return toJS(client()->transactionCount(client()->hashFromNumber(number)));
@ -422,7 +422,7 @@ string WebThreeStubServerBase::eth_getUncleCountByBlockHash(string const& _block
} }
catch (...) catch (...)
{ {
throw JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS); BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
} }
return toJS(client()->uncleCount(hash)); return toJS(client()->uncleCount(hash));
@ -438,7 +438,7 @@ string WebThreeStubServerBase::eth_getUncleCountByBlockNumber(string const& _blo
} }
catch (...) catch (...)
{ {
throw JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS); BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
} }
return toJS(client()->uncleCount(client()->hashFromNumber(number))); return toJS(client()->uncleCount(client()->hashFromNumber(number)));
@ -456,7 +456,7 @@ string WebThreeStubServerBase::eth_getData(string const& _address, string const&
} }
catch (...) catch (...)
{ {
throw JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS); BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
} }
return jsFromBinary(client()->codeAt(address, number)); return jsFromBinary(client()->codeAt(address, number));
@ -502,7 +502,7 @@ string WebThreeStubServerBase::eth_sendTransaction(Json::Value const& _json)
} }
catch (...) catch (...)
{ {
throw JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS); BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
} }
string ret; string ret;
@ -534,7 +534,7 @@ string WebThreeStubServerBase::eth_call(Json::Value const& _json)
} }
catch (...) catch (...)
{ {
throw JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS); BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
} }
string ret; string ret;
@ -567,7 +567,7 @@ Json::Value WebThreeStubServerBase::eth_getBlockByHash(string const& _blockHash,
} }
catch (...) catch (...)
{ {
throw JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS); BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
} }
if (_includeTransactions) { if (_includeTransactions) {
@ -587,7 +587,7 @@ Json::Value WebThreeStubServerBase::eth_getBlockByNumber(string const& _blockNum
} }
catch (...) catch (...)
{ {
throw JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS); BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
} }
h256 hash = client()->hashFromNumber(number); h256 hash = client()->hashFromNumber(number);
@ -609,7 +609,7 @@ Json::Value WebThreeStubServerBase::eth_getTransactionByHash(string const& _tran
} }
catch (...) catch (...)
{ {
throw JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS); BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
} }
return toJson(client()->transaction(hash)); return toJson(client()->transaction(hash));
@ -627,7 +627,7 @@ Json::Value WebThreeStubServerBase::eth_getTransactionByBlockHashAndIndex(string
} }
catch (...) catch (...)
{ {
throw JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS); BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
} }
return toJson(client()->transaction(hash, index)); return toJson(client()->transaction(hash, index));
@ -645,7 +645,7 @@ Json::Value WebThreeStubServerBase::eth_getTransactionByBlockNumberAndIndex(stri
} }
catch (...) catch (...)
{ {
throw JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS); BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
} }
return toJson(client()->transaction(client()->hashFromNumber(number), index)); return toJson(client()->transaction(client()->hashFromNumber(number), index));
@ -663,7 +663,7 @@ Json::Value WebThreeStubServerBase::eth_getUncleByBlockHashAndIndex(string const
} }
catch (...) catch (...)
{ {
throw JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS); BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
} }
return toJson(client()->uncle(hash, index)); return toJson(client()->uncle(hash, index));
@ -681,7 +681,7 @@ Json::Value WebThreeStubServerBase::eth_getUncleByBlockNumberAndIndex(string con
} }
catch (...) catch (...)
{ {
throw JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS); BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
} }
return toJson(client()->uncle(client()->hashFromNumber(number), index)); return toJson(client()->uncle(client()->hashFromNumber(number), index));
@ -762,7 +762,7 @@ string WebThreeStubServerBase::eth_newFilter(Json::Value const& _json)
} }
catch (...) catch (...)
{ {
throw JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS); BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
} }
return toJS(client()->installWatch(filter)); return toJS(client()->installWatch(filter));
@ -777,7 +777,7 @@ string WebThreeStubServerBase::eth_newBlockFilter(string const& _filter)
else if (_filter.compare("pending") == 0) else if (_filter.compare("pending") == 0)
filter = dev::eth::PendingChangedFilter; filter = dev::eth::PendingChangedFilter;
else else
throw JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS); BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
return toJS(client()->installWatch(filter)); return toJS(client()->installWatch(filter));
} }
@ -792,7 +792,7 @@ bool WebThreeStubServerBase::eth_uninstallFilter(string const& _filterId)
} }
catch (...) catch (...)
{ {
throw JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS); BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
} }
// TODO: throw an error if there is no watch with given id? // TODO: throw an error if there is no watch with given id?
@ -810,7 +810,7 @@ Json::Value WebThreeStubServerBase::eth_getFilterChanges(string const& _filterId
} }
catch (...) catch (...)
{ {
throw JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS); BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
} }
// TODO: throw an error if there is no watch with given id? // TODO: throw an error if there is no watch with given id?
@ -830,7 +830,7 @@ Json::Value WebThreeStubServerBase::eth_getFilterLogs(string const& _filterId)
} }
catch (...) catch (...)
{ {
throw JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS); BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
} }
// TODO: throw an error if there is no watch with given id? // TODO: throw an error if there is no watch with given id?
@ -847,7 +847,7 @@ Json::Value WebThreeStubServerBase::eth_getLogs(Json::Value const& _json)
} }
catch (...) catch (...)
{ {
throw JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS); BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
} }
return toJson(client()->logs(filter)); return toJson(client()->logs(filter));
@ -875,7 +875,7 @@ bool WebThreeStubServerBase::eth_submitWork(string const& _nonce, string const&
} }
catch (...) catch (...)
{ {
throw JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS); BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
} }
return client()->submitWork(ProofOfWork::Proof{nonce, mixHash}); return client()->submitWork(ProofOfWork::Proof{nonce, mixHash});
@ -891,7 +891,7 @@ string WebThreeStubServerBase::eth_register(string const& _address)
} }
catch (...) catch (...)
{ {
throw JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS); BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
} }
return toJS(m_accounts->addProxyAccount(address)); return toJS(m_accounts->addProxyAccount(address));
@ -907,7 +907,7 @@ bool WebThreeStubServerBase::eth_unregister(string const& _accountId)
} }
catch (...) catch (...)
{ {
throw JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS); BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
} }
// TODO: throw an error on no account with given id // TODO: throw an error on no account with given id
@ -924,7 +924,7 @@ Json::Value WebThreeStubServerBase::eth_queuedTransactions(string const& _accoun
} }
catch (...) catch (...)
{ {
throw JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS); BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
} }
// TODO: throw an error on no account with given id // TODO: throw an error on no account with given id
@ -955,7 +955,7 @@ bool WebThreeStubServerBase::shh_post(Json::Value const& _json)
} }
catch (...) catch (...)
{ {
throw JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS); BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
} }
Secret from; Secret from;
@ -987,7 +987,7 @@ bool WebThreeStubServerBase::shh_hasIdentity(string const& _identity)
} }
catch (...) catch (...)
{ {
throw JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS); BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
} }
return m_ids.count(identity) > 0; return m_ids.count(identity) > 0;
@ -1018,7 +1018,7 @@ string WebThreeStubServerBase::shh_newFilter(Json::Value const& _json)
} }
catch (...) catch (...)
{ {
throw JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS); BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
} }
auto ret = face()->installWatch(w.first); auto ret = face()->installWatch(w.first);
@ -1037,7 +1037,7 @@ bool WebThreeStubServerBase::shh_uninstallFilter(string const& _filterId)
} }
catch (...) catch (...)
{ {
throw JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS); BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
} }
face()->uninstallWatch(id); face()->uninstallWatch(id);
@ -1054,7 +1054,7 @@ Json::Value WebThreeStubServerBase::shh_getFilterChanges(string const& _filterId
} }
catch (...) catch (...)
{ {
throw JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS); BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
} }
Json::Value ret(Json::arrayValue); Json::Value ret(Json::arrayValue);
@ -1089,7 +1089,7 @@ Json::Value WebThreeStubServerBase::shh_getMessages(string const& _filterId)
} }
catch (...) catch (...)
{ {
throw JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS); BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
} }
Json::Value ret(Json::arrayValue); Json::Value ret(Json::arrayValue);

Loading…
Cancel
Save