Browse Source

Merge pull request #2255 from CJentzsch/useBoosThrowException

use boost throw exceptions
cl-refactor
Gav Wood 10 years ago
parent
commit
f4a1e534d8
  1. 5
      CMakeLists.txt
  2. 20
      ethminer/MinerAux.h
  3. 2
      libdevcore/RLP.h
  4. 4
      libethcore/BlockInfo.cpp
  5. 16
      libethcore/ICAP.cpp
  6. 2
      libethcore/KeyManager.h
  7. 2
      libethereum/State.cpp

5
CMakeLists.txt

@ -84,7 +84,10 @@ function(configureProject)
add_definitions(-DETH_CURL) add_definitions(-DETH_CURL)
endif() endif()
add_definitions(-DNOBOOST) if (NOBOOST)
add_definitions(-DNOBOOST)
endif()
add_definitions(-DETH_TRUE) add_definitions(-DETH_TRUE)
endfunction() endfunction()

20
ethminer/MinerAux.h

@ -107,7 +107,7 @@ public:
catch (...) catch (...)
{ {
cerr << "Bad " << arg << " option: " << argv[i] << endl; cerr << "Bad " << arg << " option: " << argv[i] << endl;
throw BadArgument(); BOOST_THROW_EXCEPTION(BadArgument());
} }
else if (arg == "--opencl-platform" && i + 1 < argc) else if (arg == "--opencl-platform" && i + 1 < argc)
try { try {
@ -116,7 +116,7 @@ public:
catch (...) catch (...)
{ {
cerr << "Bad " << arg << " option: " << argv[i] << endl; cerr << "Bad " << arg << " option: " << argv[i] << endl;
throw BadArgument(); BOOST_THROW_EXCEPTION(BadArgument());
} }
else if (arg == "--opencl-device" && i + 1 < argc) else if (arg == "--opencl-device" && i + 1 < argc)
try { try {
@ -126,7 +126,7 @@ public:
catch (...) catch (...)
{ {
cerr << "Bad " << arg << " option: " << argv[i] << endl; cerr << "Bad " << arg << " option: " << argv[i] << endl;
throw BadArgument(); BOOST_THROW_EXCEPTION(BadArgument());
} }
else if (arg == "--list-devices") else if (arg == "--list-devices")
m_shouldListDevices = true; m_shouldListDevices = true;
@ -144,7 +144,7 @@ public:
else else
{ {
cerr << "Bad " << arg << " option: " << m << endl; cerr << "Bad " << arg << " option: " << m << endl;
throw BadArgument(); BOOST_THROW_EXCEPTION(BadArgument());
} }
} }
else if (arg == "--benchmark-warmup" && i + 1 < argc) else if (arg == "--benchmark-warmup" && i + 1 < argc)
@ -154,7 +154,7 @@ public:
catch (...) catch (...)
{ {
cerr << "Bad " << arg << " option: " << argv[i] << endl; cerr << "Bad " << arg << " option: " << argv[i] << endl;
throw BadArgument(); BOOST_THROW_EXCEPTION(BadArgument());
} }
else if (arg == "--benchmark-trial" && i + 1 < argc) else if (arg == "--benchmark-trial" && i + 1 < argc)
try { try {
@ -163,7 +163,7 @@ public:
catch (...) catch (...)
{ {
cerr << "Bad " << arg << " option: " << argv[i] << endl; cerr << "Bad " << arg << " option: " << argv[i] << endl;
throw BadArgument(); BOOST_THROW_EXCEPTION(BadArgument());
} }
else if (arg == "--benchmark-trials" && i + 1 < argc) else if (arg == "--benchmark-trials" && i + 1 < argc)
try { try {
@ -172,7 +172,7 @@ public:
catch (...) catch (...)
{ {
cerr << "Bad " << arg << " option: " << argv[i] << endl; cerr << "Bad " << arg << " option: " << argv[i] << endl;
throw BadArgument(); BOOST_THROW_EXCEPTION(BadArgument());
} }
else if (arg == "-C" || arg == "--cpu") else if (arg == "-C" || arg == "--cpu")
m_minerType = MinerType::CPU; m_minerType = MinerType::CPU;
@ -195,7 +195,7 @@ public:
catch (...) catch (...)
{ {
cerr << "Bad " << arg << " option: " << m << endl; cerr << "Bad " << arg << " option: " << m << endl;
throw BadArgument(); BOOST_THROW_EXCEPTION(BadArgument());
} }
} }
else if ((arg == "-w" || arg == "--check-pow") && i + 4 < argc) else if ((arg == "-w" || arg == "--check-pow") && i + 4 < argc)
@ -232,7 +232,7 @@ public:
catch (...) catch (...)
{ {
cerr << "Bad " << arg << " option: " << m << endl; cerr << "Bad " << arg << " option: " << m << endl;
throw BadArgument(); BOOST_THROW_EXCEPTION(BadArgument());
} }
} }
else if (arg == "-M" || arg == "--benchmark") else if (arg == "-M" || arg == "--benchmark")
@ -245,7 +245,7 @@ public:
catch (...) catch (...)
{ {
cerr << "Bad " << arg << " option: " << argv[i] << endl; cerr << "Bad " << arg << " option: " << argv[i] << endl;
throw BadArgument(); BOOST_THROW_EXCEPTION(BadArgument());
} }
} }
else else

2
libdevcore/RLP.h

@ -292,7 +292,7 @@ public:
RLPs toList() const; RLPs toList() const;
/// @returns the data payload. Valid for all types. /// @returns the data payload. Valid for all types.
bytesConstRef payload() const { auto l = length(); if (l > m_data.size()) throw BadRLP(); return m_data.cropped(payloadOffset(), l); } bytesConstRef payload() const { auto l = length(); if (l > m_data.size()) BOOST_THROW_EXCEPTION(BadRLP()); return m_data.cropped(payloadOffset(), l); }
/// @returns the theoretical size of this item. /// @returns the theoretical size of this item.
/// @note Under normal circumstances, is equivalent to m_data.size() - use that unless you know it won't work. /// @note Under normal circumstances, is equivalent to m_data.size() - use that unless you know it won't work.

4
libethcore/BlockInfo.cpp

@ -122,7 +122,7 @@ void BlockInfo::populateFromHeader(RLP const& _header, Strictness _s, h256 const
try try
{ {
if (_header.itemCount() != 15) if (_header.itemCount() != 15)
throw InvalidBlockHeaderItemCount(); BOOST_THROW_EXCEPTION(InvalidBlockHeaderItemCount());
parentHash = _header[field = 0].toHash<h256>(RLP::VeryStrict); parentHash = _header[field = 0].toHash<h256>(RLP::VeryStrict);
sha3Uncles = _header[field = 1].toHash<h256>(RLP::VeryStrict); sha3Uncles = _header[field = 1].toHash<h256>(RLP::VeryStrict);
coinbaseAddress = _header[field = 2].toHash<Address>(RLP::VeryStrict); coinbaseAddress = _header[field = 2].toHash<Address>(RLP::VeryStrict);
@ -146,7 +146,7 @@ void BlockInfo::populateFromHeader(RLP const& _header, Strictness _s, h256 const
} }
if (number > ~(unsigned)0) if (number > ~(unsigned)0)
throw InvalidNumber(); BOOST_THROW_EXCEPTION(InvalidNumber());
// check it hashes according to proof of work or that it's the genesis block. // check it hashes according to proof of work or that it's the genesis block.
if (_s == CheckEverything && parentHash && !ProofOfWork::verify(*this)) if (_s == CheckEverything && parentHash && !ProofOfWork::verify(*this))

16
libethcore/ICAP.cpp

@ -71,7 +71,7 @@ ICAP ICAP::decoded(std::string const& _encoded)
std::string data; std::string data;
std::tie(country, data) = fromIBAN(_encoded); std::tie(country, data) = fromIBAN(_encoded);
if (country != "XE") if (country != "XE")
throw InvalidICAP(); BOOST_THROW_EXCEPTION(InvalidICAP());
if (data.size() == 30) if (data.size() == 30)
{ {
ret.m_type = Direct; ret.m_type = Direct;
@ -88,10 +88,10 @@ ICAP ICAP::decoded(std::string const& _encoded)
ret.m_client = data.substr(7); ret.m_client = data.substr(7);
} }
else else
throw InvalidICAP(); BOOST_THROW_EXCEPTION(InvalidICAP());
} }
else else
throw InvalidICAP(); BOOST_THROW_EXCEPTION(InvalidICAP());
return ret; return ret;
} }
@ -101,7 +101,7 @@ std::string ICAP::encoded() const
if (m_type == Direct) if (m_type == Direct)
{ {
if (!!m_direct[0]) if (!!m_direct[0])
throw InvalidICAP(); BOOST_THROW_EXCEPTION(InvalidICAP());
std::string d = toBase36<Address::size>(m_direct); std::string d = toBase36<Address::size>(m_direct);
while (d.size() < 30) while (d.size() < 30)
d = "0" + d; d = "0" + d;
@ -118,11 +118,11 @@ std::string ICAP::encoded() const
m_institution.size() != 4 || m_institution.size() != 4 ||
m_client.size() != 9 m_client.size() != 9
) )
throw InvalidICAP(); BOOST_THROW_EXCEPTION(InvalidICAP());
return iban("XE", m_asset + m_institution + m_client); return iban("XE", m_asset + m_institution + m_client);
} }
else else
throw InvalidICAP(); BOOST_THROW_EXCEPTION(InvalidICAP());
} }
pair<Address, bytes> ICAP::lookup(std::function<bytes(Address, bytes)> const& _call, Address const& _reg) const pair<Address, bytes> ICAP::lookup(std::function<bytes(Address, bytes)> const& _call, Address const& _reg) const
@ -149,9 +149,9 @@ pair<Address, bytes> ICAP::lookup(std::function<bytes(Address, bytes)> const& _c
else if (m_institution[0] != 'X') else if (m_institution[0] != 'X')
return make_pair(resolve(m_institution + "/" + m_client), bytes()); return make_pair(resolve(m_institution + "/" + m_client), bytes());
else else
throw InterfaceNotSupported("ICAP::lookup(), bad institution"); BOOST_THROW_EXCEPTION(InterfaceNotSupported("ICAP::lookup(), bad institution"));
} }
throw InterfaceNotSupported("ICAP::lookup(), bad asset"); BOOST_THROW_EXCEPTION(InterfaceNotSupported("ICAP::lookup(), bad asset"));
} }
} }

2
libethcore/KeyManager.h

@ -46,7 +46,7 @@ struct KeyInfo
static h256 const UnknownPassword; static h256 const UnknownPassword;
/// Password query function that never returns a password. /// Password query function that never returns a password.
static auto const DontKnowThrow = [](){ throw PasswordUnknown(); return std::string(); }; static auto const DontKnowThrow = [](){ BOOST_THROW_EXCEPTION(PasswordUnknown()); return std::string(); };
enum class SemanticPassword enum class SemanticPassword
{ {

2
libethereum/State.cpp

@ -456,7 +456,7 @@ unordered_map<Address, u256> State::addresses() const
ret[i.first] = RLP(i.second)[1].toInt<u256>(); ret[i.first] = RLP(i.second)[1].toInt<u256>();
return ret; return ret;
#else #else
throw InterfaceNotSupported("State::addresses()"); BOOST_THROW_EXCEPTION(InterfaceNotSupported("State::addresses()"));
#endif #endif
} }

Loading…
Cancel
Save