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)
endif()
add_definitions(-DNOBOOST)
if (NOBOOST)
add_definitions(-DNOBOOST)
endif()
add_definitions(-DETH_TRUE)
endfunction()

20
ethminer/MinerAux.h

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

2
libdevcore/RLP.h

@ -292,7 +292,7 @@ public:
RLPs toList() const;
/// @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.
/// @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
{
if (_header.itemCount() != 15)
throw InvalidBlockHeaderItemCount();
BOOST_THROW_EXCEPTION(InvalidBlockHeaderItemCount());
parentHash = _header[field = 0].toHash<h256>(RLP::VeryStrict);
sha3Uncles = _header[field = 1].toHash<h256>(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)
throw InvalidNumber();
BOOST_THROW_EXCEPTION(InvalidNumber());
// check it hashes according to proof of work or that it's the genesis block.
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::tie(country, data) = fromIBAN(_encoded);
if (country != "XE")
throw InvalidICAP();
BOOST_THROW_EXCEPTION(InvalidICAP());
if (data.size() == 30)
{
ret.m_type = Direct;
@ -88,10 +88,10 @@ ICAP ICAP::decoded(std::string const& _encoded)
ret.m_client = data.substr(7);
}
else
throw InvalidICAP();
BOOST_THROW_EXCEPTION(InvalidICAP());
}
else
throw InvalidICAP();
BOOST_THROW_EXCEPTION(InvalidICAP());
return ret;
}
@ -101,7 +101,7 @@ std::string ICAP::encoded() const
if (m_type == Direct)
{
if (!!m_direct[0])
throw InvalidICAP();
BOOST_THROW_EXCEPTION(InvalidICAP());
std::string d = toBase36<Address::size>(m_direct);
while (d.size() < 30)
d = "0" + d;
@ -118,11 +118,11 @@ std::string ICAP::encoded() const
m_institution.size() != 4 ||
m_client.size() != 9
)
throw InvalidICAP();
BOOST_THROW_EXCEPTION(InvalidICAP());
return iban("XE", m_asset + m_institution + m_client);
}
else
throw InvalidICAP();
BOOST_THROW_EXCEPTION(InvalidICAP());
}
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')
return make_pair(resolve(m_institution + "/" + m_client), bytes());
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;
/// 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
{

2
libethereum/State.cpp

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

Loading…
Cancel
Save