Convert throws and catch alls (RIPD-1046)

This commit is contained in:
Miguel Portilla
2015-11-11 10:47:21 -05:00
committed by Nik Bougalis
parent 0633ef1ba1
commit 880f354b90
127 changed files with 786 additions and 710 deletions

View File

@@ -20,6 +20,7 @@
#ifndef RIPPLE_PROTOCOL_KNOWNFORMATS_H_INCLUDED
#define RIPPLE_PROTOCOL_KNOWNFORMATS_H_INCLUDED
#include <ripple/basics/contract.h>
#include <ripple/protocol/SOTemplate.h>
#include <memory>
@@ -110,13 +111,9 @@ public:
Item const* const result = findByName (name);
if (result != nullptr)
{
return result->getType ();
}
else
{
throw std::runtime_error ("Unknown format name");
}
Throw<std::runtime_error> ("Unknown format name");
return {}; // Silence compiler warning.
}
/** Retrieve a format based on its type.

View File

@@ -20,6 +20,7 @@
#ifndef RIPPLE_PROTOCOL_STBASE_H_INCLUDED
#define RIPPLE_PROTOCOL_STBASE_H_INCLUDED
#include <ripple/basics/contract.h>
#include <ripple/protocol/SField.h>
#include <ripple/protocol/Serializer.h>
#include <ostream>
@@ -91,7 +92,7 @@ public:
{
D* ptr = dynamic_cast<D*> (this);
if (ptr == nullptr)
throw std::bad_cast();
Throw<std::bad_cast> ();
return *ptr;
}
@@ -101,7 +102,7 @@ public:
{
D const * ptr = dynamic_cast<D const*> (this);
if (ptr == nullptr)
throw std::bad_cast();
Throw<std::bad_cast> ();
return *ptr;
}

View File

@@ -21,6 +21,7 @@
#define RIPPLE_PROTOCOL_STEXCHANGE_H_INCLUDED
#include <ripple/basics/Buffer.h>
#include <ripple/basics/contract.h>
#include <ripple/basics/Slice.h>
#include <ripple/protocol/SField.h>
#include <ripple/protocol/STBlob.h>
@@ -139,7 +140,7 @@ get (STObject const& st,
dynamic_cast<U const*>(b);
// This should never happen
if (! u)
throw std::runtime_error (
Throw<std::runtime_error> (
"Wrong field type");
STExchange<U, T>::get(t, *u);
return t;

View File

@@ -533,8 +533,8 @@ public:
{
STBase* rf = getPField (field, true);
if (!rf)
throw std::runtime_error ("Field not found");
if (! rf)
Throw<std::runtime_error> ("Field not found");
if (rf->getSType () == STI_NOTPRESENT)
rf = makeFieldPresent (field);
@@ -543,7 +543,7 @@ public:
if (auto cf = dynamic_cast<Bits*> (rf))
cf->setValue (v);
else
throw std::runtime_error ("Wrong field type");
Throw<std::runtime_error> ("Wrong field type");
}
STObject& peekFieldObject (SField const& field);
@@ -594,8 +594,8 @@ private:
{
const STBase* rf = peekAtPField (field);
if (!rf)
throw std::runtime_error ("Field not found");
if (! rf)
Throw<std::runtime_error> ("Field not found");
SerializedTypeID id = rf->getSType ();
@@ -604,8 +604,8 @@ private:
const T* cf = dynamic_cast<const T*> (rf);
if (!cf)
throw std::runtime_error ("Wrong field type");
if (! cf)
Throw<std::runtime_error> ("Wrong field type");
return cf->value ();
}
@@ -620,8 +620,8 @@ private:
{
const STBase* rf = peekAtPField (field);
if (!rf)
throw std::runtime_error ("Field not found");
if (! rf)
Throw<std::runtime_error> ("Field not found");
SerializedTypeID id = rf->getSType ();
@@ -630,8 +630,8 @@ private:
const T* cf = dynamic_cast<const T*> (rf);
if (!cf)
throw std::runtime_error ("Wrong field type");
if (! cf)
Throw<std::runtime_error> ("Wrong field type");
return *cf;
}
@@ -644,16 +644,16 @@ private:
STBase* rf = getPField (field, true);
if (!rf)
throw std::runtime_error ("Field not found");
if (! rf)
Throw<std::runtime_error> ("Field not found");
if (rf->getSType () == STI_NOTPRESENT)
rf = makeFieldPresent (field);
T* cf = dynamic_cast<T*> (rf);
if (!cf)
throw std::runtime_error ("Wrong field type");
if (! cf)
Throw<std::runtime_error> ("Wrong field type");
cf->setValue (std::move (value));
}
@@ -664,16 +664,16 @@ private:
{
STBase* rf = getPField (field, true);
if (!rf)
throw std::runtime_error ("Field not found");
if (! rf)
Throw<std::runtime_error> ("Field not found");
if (rf->getSType () == STI_NOTPRESENT)
rf = makeFieldPresent (field);
T* cf = dynamic_cast<T*> (rf);
if (!cf)
throw std::runtime_error ("Wrong field type");
if (! cf)
Throw<std::runtime_error> ("Wrong field type");
(*cf) = value;
}
@@ -684,16 +684,16 @@ private:
{
STBase* rf = getPField (field, true);
if (!rf)
throw std::runtime_error ("Field not found");
if (! rf)
Throw<std::runtime_error> ("Field not found");
if (rf->getSType () == STI_NOTPRESENT)
rf = makeFieldPresent (field);
T* cf = dynamic_cast<T*> (rf);
if (!cf)
throw std::runtime_error ("Wrong field type");
if (! cf)
Throw<std::runtime_error> ("Wrong field type");
return *cf;
}
@@ -710,7 +710,7 @@ STObject::Proxy<T>::Proxy (STObject* st, TypedField<T> const* f)
{
// STObject has associated template
if (! st_->peekAtPField(*f_))
THROW(template_field_error, *f);
Throw<template_field_error> (*f);
style_ = st_->mType->style(*f_);
}
else
@@ -728,7 +728,7 @@ STObject::Proxy<T>::value() const ->
if (t)
return t->value();
if (style_ != SOE_DEFAULT)
THROW(missing_field_error, *f_);
Throw<missing_field_error> (*f_);
return value_type{};
}
@@ -884,7 +884,7 @@ STObject::OptionalProxy<T>::disengage()
{
if (this->style_ == SOE_REQUIRED ||
this->style_ == SOE_DEFAULT)
THROW(template_field_error, *this->f_);
Throw<template_field_error> (*this->f_);
if (this->style_ == SOE_INVALID)
this->st_->delField(*this->f_);
else
@@ -911,7 +911,7 @@ STObject::operator[](TypedField<T> const& f) const
if (! b)
// This is a free object (no constraints)
// with no template
THROW(missing_field_error, f);
Throw<missing_field_error> (f);
auto const u =
dynamic_cast<T const*>(b);
if (! u)
@@ -919,7 +919,7 @@ STObject::operator[](TypedField<T> const& f) const
assert(mType);
assert(b->getSType() == STI_NOTPRESENT);
if(mType->style(f) == SOE_OPTIONAL)
THROW(missing_field_error, f);
Throw<missing_field_error> (f);
assert(mType->style(f) == SOE_DEFAULT);
// Handle the case where value_type is a
// const reference, otherwise we return

View File

@@ -22,6 +22,7 @@
#include <ripple/protocol/SField.h>
#include <ripple/basics/base_uint.h>
#include <ripple/basics/contract.h>
#include <ripple/basics/Buffer.h>
#include <ripple/basics/Slice.h>
#include <cassert>
@@ -386,7 +387,7 @@ SerialIter::getBitString()
base_uint<Bits, Tag> u;
auto const n = Bits/8;
if (remain_ < n)
throw std::runtime_error(
Throw<std::runtime_error> (
"invalid SerialIter getBitString");
std::memcpy (u.begin(), p_, n);
p_ += n;

View File

@@ -18,6 +18,7 @@
//==============================================================================
#include <BeastConfig.h>
#include <ripple/basics/contract.h>
#include <ripple/protocol/ErrorCodes.h>
#include <unordered_map>
#include <utility>
@@ -132,7 +133,7 @@ private:
std::forward_as_tuple (code), std::forward_as_tuple (
code, token, message)));
if (! result.second)
throw std::invalid_argument ("duplicate error code");
Throw<std::invalid_argument> ("duplicate error code");
}
private:

View File

@@ -18,6 +18,7 @@
//==============================================================================
#include <BeastConfig.h>
#include <ripple/basics/contract.h>
#include <ripple/protocol/IOUAmount.h>
#include <algorithm>
#include <iterator>
@@ -56,7 +57,7 @@ IOUAmount::normalize ()
while (mantissa_ > maxMantissa)
{
if (exponent_ >= maxExponent)
throw std::overflow_error ("IOUAmount::normalize");
Throw<std::overflow_error> ("IOUAmount::normalize");
mantissa_ /= 10;
++exponent_;
@@ -69,7 +70,7 @@ IOUAmount::normalize ()
}
if (exponent_ > maxExponent)
throw std::overflow_error ("value overflow");
Throw<std::overflow_error> ("value overflow");
if (negative)
mantissa_ = -mantissa_;

View File

@@ -18,8 +18,8 @@
//==============================================================================
#include <BeastConfig.h>
#include <ripple/basics/contract.h>
#include <ripple/basics/Log.h>
#include <ripple/protocol/digest.h>
#include <ripple/basics/StringUtilities.h>
#include <ripple/crypto/ECDSA.h>
#include <ripple/crypto/ECIES.h>
@@ -151,20 +151,15 @@ RippleAddress::toPublicKey() const
return RipplePublicKey (vchData.begin(), vchData.end());
}
static
std::runtime_error badSourceError (int nVersion)
{
return std::runtime_error ("bad source: " + std::to_string (nVersion));
}
NodeID RippleAddress::getNodeID () const
{
switch (nVersion)
{
case TOKEN_NONE:
throw std::runtime_error ("unset source - getNodeID");
Throw<std::runtime_error> ("unset source - getNodeID");
case TOKEN_NODE_PUBLIC: {
case TOKEN_NODE_PUBLIC:
{
// Note, we are encoding the left.
NodeID node;
node.copyFrom(Hash160 (vchData));
@@ -172,8 +167,9 @@ NodeID RippleAddress::getNodeID () const
}
default:
throw badSourceError (nVersion);
Throw<std::runtime_error> ("bad source: " + std::to_string(nVersion));
}
return {}; // Silence compiler warning.
}
Blob const& RippleAddress::getNodePublic () const
@@ -181,14 +177,15 @@ Blob const& RippleAddress::getNodePublic () const
switch (nVersion)
{
case TOKEN_NONE:
throw std::runtime_error ("unset source - getNodePublic");
Throw<std::runtime_error> ("unset source - getNodePublic");
case TOKEN_NODE_PUBLIC:
return vchData;
default:
throw badSourceError (nVersion);
Throw<std::runtime_error>("bad source: " + std::to_string(nVersion));
}
return vchData; // Silence compiler warning.
}
std::string RippleAddress::humanNodePublic () const
@@ -196,14 +193,15 @@ std::string RippleAddress::humanNodePublic () const
switch (nVersion)
{
case TOKEN_NONE:
throw std::runtime_error ("unset source - humanNodePublic");
Throw<std::runtime_error> ("unset source - humanNodePublic");
case TOKEN_NODE_PUBLIC:
return ToString ();
default:
throw badSourceError (nVersion);
Throw<std::runtime_error>("bad source: " + std::to_string(nVersion));
}
return {}; // Silence compiler warning.
}
bool RippleAddress::setNodePublic (std::string const& strPublic)
@@ -253,14 +251,15 @@ Blob const& RippleAddress::getNodePrivateData () const
switch (nVersion)
{
case TOKEN_NONE:
throw std::runtime_error ("unset source - getNodePrivateData");
Throw<std::runtime_error> ("unset source - getNodePrivateData");
case TOKEN_NODE_PRIVATE:
return vchData;
default:
throw badSourceError (nVersion);
Throw<std::runtime_error> ("bad source: " + std::to_string(nVersion));
}
return vchData; // Silence compiler warning.
}
uint256 RippleAddress::getNodePrivate () const
@@ -268,14 +267,15 @@ uint256 RippleAddress::getNodePrivate () const
switch (nVersion)
{
case TOKEN_NONE:
throw std::runtime_error ("unset source = getNodePrivate");
Throw<std::runtime_error> ("unset source = getNodePrivate");
case TOKEN_NODE_PRIVATE:
return uint256 (vchData);
default:
throw badSourceError (nVersion);
Throw<std::runtime_error> ("bad source: " + std::to_string(nVersion));
}
return {}; // Silence compiler warning.
}
std::string RippleAddress::humanNodePrivate () const
@@ -283,14 +283,15 @@ std::string RippleAddress::humanNodePrivate () const
switch (nVersion)
{
case TOKEN_NONE:
throw std::runtime_error ("unset source - humanNodePrivate");
Throw<std::runtime_error> ("unset source - humanNodePrivate");
case TOKEN_NODE_PRIVATE:
return ToString ();
default:
throw badSourceError (nVersion);
Throw<std::runtime_error> ("bad source: " + std::to_string(nVersion));
}
return {}; // Silence compiler warning.
}
bool RippleAddress::setNodePrivate (std::string const& strPrivate)
@@ -320,7 +321,7 @@ void RippleAddress::signNodePrivate (uint256 const& hash, Blob& vchSig) const
vchSig = ECDSASign (hash, getNodePrivate());
if (vchSig.empty())
throw std::runtime_error ("Signing failed.");
Throw<std::runtime_error> ("Signing failed.");
}
//
@@ -342,18 +343,18 @@ Blob const& RippleAddress::getAccountPublic () const
switch (nVersion)
{
case TOKEN_NONE:
throw std::runtime_error ("unset source - getAccountPublic");
Throw<std::runtime_error> ("unset source - getAccountPublic");
case TOKEN_ACCOUNT_ID:
throw std::runtime_error ("public not available from account id");
break;
Throw<std::runtime_error> ("public not available from account id");
case TOKEN_ACCOUNT_PUBLIC:
return vchData;
default:
throw badSourceError (nVersion);
Throw<std::runtime_error> ("bad source: " + std::to_string(nVersion));
}
return vchData; // Silence compiler warning.
}
std::string RippleAddress::humanAccountPublic () const
@@ -361,17 +362,18 @@ std::string RippleAddress::humanAccountPublic () const
switch (nVersion)
{
case TOKEN_NONE:
throw std::runtime_error ("unset source - humanAccountPublic");
Throw<std::runtime_error> ("unset source - humanAccountPublic");
case TOKEN_ACCOUNT_ID:
throw std::runtime_error ("public not available from account id");
Throw<std::runtime_error> ("public not available from account id");
case TOKEN_ACCOUNT_PUBLIC:
return ToString ();
default:
throw badSourceError (nVersion);
Throw<std::runtime_error> ("bad source: " + std::to_string(nVersion));
}
return {}; // Silence compiler warning.
}
bool RippleAddress::setAccountPublic (std::string const& strPublic)
@@ -437,14 +439,15 @@ uint256 RippleAddress::getAccountPrivate () const
switch (nVersion)
{
case TOKEN_NONE:
throw std::runtime_error ("unset source - getAccountPrivate");
Throw<std::runtime_error> ("unset source - getAccountPrivate");
case TOKEN_ACCOUNT_SECRET:
return uint256::fromVoid (vchData.data() + (vchData.size() - 32));
default:
throw badSourceError (nVersion);
Throw<std::runtime_error> ("bad source: " + std::to_string(nVersion));
}
return {}; // Silence compiler warning.
}
bool RippleAddress::setAccountPrivate (std::string const& strPrivate)
@@ -518,7 +521,7 @@ Blob RippleAddress::accountPrivateEncrypt (
{
vucCipherText = encryptECIES (secretKey, publicKey, vucPlainText);
}
catch (...)
catch (std::exception const&)
{
// TODO: log this or explain why this is unimportant!
}
@@ -540,7 +543,7 @@ Blob RippleAddress::accountPrivateDecrypt (
{
vucPlainText = decryptECIES (secretKey, publicKey, vucCipherText);
}
catch (...)
catch (std::exception const&)
{
// TODO: log this or explain why this is unimportant!
}
@@ -559,15 +562,16 @@ Blob const& RippleAddress::getGenerator () const
switch (nVersion)
{
case TOKEN_NONE:
throw std::runtime_error ("unset source - getGenerator");
Throw<std::runtime_error> ("unset source - getGenerator");
case TOKEN_FAMILY_GENERATOR:
// Do nothing.
return vchData;
default:
throw badSourceError (nVersion);
Throw<std::runtime_error> ("bad source: " + std::to_string(nVersion));
}
return vchData; // Silence compiler warning.
}
std::string RippleAddress::humanGenerator () const
@@ -575,14 +579,15 @@ std::string RippleAddress::humanGenerator () const
switch (nVersion)
{
case TOKEN_NONE:
throw std::runtime_error ("unset source - humanGenerator");
Throw<std::runtime_error> ("unset source - humanGenerator");
case TOKEN_FAMILY_GENERATOR:
return ToString ();
default:
throw badSourceError (nVersion);
Throw<std::runtime_error> ("bad source: " + std::to_string(nVersion));
}
return {}; // Silence compiler warning.
}
void RippleAddress::setGenerator (Blob const& vPublic)
@@ -607,14 +612,15 @@ uint128 RippleAddress::getSeed () const
switch (nVersion)
{
case TOKEN_NONE:
throw std::runtime_error ("unset source - getSeed");
Throw<std::runtime_error> ("unset source - getSeed");
case TOKEN_FAMILY_SEED:
return uint128 (vchData);
default:
throw badSourceError (nVersion);
Throw<std::runtime_error> ("bad source: " + std::to_string(nVersion));
}
return {}; // Silence compiler warning.
}
std::string RippleAddress::humanSeed1751 () const
@@ -622,7 +628,7 @@ std::string RippleAddress::humanSeed1751 () const
switch (nVersion)
{
case TOKEN_NONE:
throw std::runtime_error ("unset source - humanSeed1751");
Throw<std::runtime_error> ("unset source - humanSeed1751");
case TOKEN_FAMILY_SEED:
{
@@ -641,8 +647,9 @@ std::string RippleAddress::humanSeed1751 () const
}
default:
throw badSourceError (nVersion);
Throw<std::runtime_error> ("bad source: " + std::to_string(nVersion));
}
return {}; // Silence compiler warning.
}
std::string RippleAddress::humanSeed () const
@@ -650,14 +657,15 @@ std::string RippleAddress::humanSeed () const
switch (nVersion)
{
case TOKEN_NONE:
throw std::runtime_error ("unset source - humanSeed");
Throw<std::runtime_error> ("unset source - humanSeed");
case TOKEN_FAMILY_SEED:
return ToString ();
default:
throw badSourceError (nVersion);
Throw<std::runtime_error> ("bad source: " + std::to_string(nVersion));
}
return {}; // Silence compiler warning.
}
int RippleAddress::setSeed1751 (std::string const& strHuman1751)

View File

@@ -45,7 +45,7 @@ std::int64_t
getSNValue (STAmount const& amount)
{
if (!amount.native ())
throw std::runtime_error ("amount is not native!");
Throw<std::runtime_error> ("amount is not native!");
auto ret = static_cast<std::int64_t>(amount.mantissa ());
@@ -85,7 +85,7 @@ STAmount::STAmount(SerialIter& sit, SField const& name)
// negative
if (value == 0)
throw std::runtime_error ("negative zero is not canonical");
Throw<std::runtime_error> ("negative zero is not canonical");
mValue = value;
mOffset = 0;
@@ -98,12 +98,12 @@ STAmount::STAmount(SerialIter& sit, SField const& name)
issue.currency.copyFrom (sit.get160 ());
if (isXRP (issue.currency))
throw std::runtime_error ("invalid native currency");
Throw<std::runtime_error> ("invalid native currency");
issue.account.copyFrom (sit.get160 ());
if (isXRP (issue.account))
throw std::runtime_error ("invalid native account");
Throw<std::runtime_error> ("invalid native account");
// 10 bits for the offset, sign and "not native" flag
int offset = static_cast<int>(value >> (64 - 10));
@@ -120,7 +120,7 @@ STAmount::STAmount(SerialIter& sit, SField const& name)
offset < cMinOffset ||
offset > cMaxOffset)
{
throw std::runtime_error ("invalid currency value");
Throw<std::runtime_error> ("invalid currency value");
}
mIssue = issue;
@@ -132,7 +132,7 @@ STAmount::STAmount(SerialIter& sit, SField const& name)
}
if (offset != 512)
throw std::runtime_error ("invalid currency value");
Throw<std::runtime_error> ("invalid currency value");
mIssue = issue;
mValue = 0;
@@ -290,7 +290,7 @@ STAmount::construct (SerialIter& sit, SField const& name)
XRPAmount STAmount::xrp () const
{
if (!mIsNative)
throw std::logic_error ("Cannot return non-native STAmount as XRPAmount");
Throw<std::logic_error> ("Cannot return non-native STAmount as XRPAmount");
auto drops = static_cast<std::int64_t> (mValue);
@@ -303,7 +303,7 @@ XRPAmount STAmount::xrp () const
IOUAmount STAmount::iou () const
{
if (mIsNative)
throw std::logic_error ("Cannot return native STAmount as IOUAmount");
Throw<std::logic_error> ("Cannot return native STAmount as IOUAmount");
auto mantissa = static_cast<std::int64_t> (mValue);
auto exponent = mOffset;
@@ -335,7 +335,7 @@ STAmount& STAmount::operator-= (STAmount const& a)
STAmount operator+ (STAmount const& v1, STAmount const& v2)
{
if (!areComparable (v1, v2))
throw std::runtime_error ("Can't add amounts that are't comparable!");
Throw<std::runtime_error> ("Can't add amounts that are't comparable!");
if (v2 == zero)
return v1;
@@ -430,7 +430,7 @@ getRate (STAmount const& offerOut, STAmount const& offerIn)
std::uint64_t ret = r.exponent() + 100;
return (ret << (64 - 8)) | r.mantissa();
}
catch (...)
catch (std::exception const&)
{
}
@@ -651,7 +651,7 @@ void STAmount::canonicalize ()
}
if (mValue > cMaxNativeN)
throw std::runtime_error ("Native currency amount out of range");
Throw<std::runtime_error> ("Native currency amount out of range");
return;
}
@@ -674,7 +674,7 @@ void STAmount::canonicalize ()
while (mValue > cMaxValue)
{
if (mOffset >= cMaxOffset)
throw std::runtime_error ("value overflow");
Throw<std::runtime_error> ("value overflow");
mValue /= 10;
++mOffset;
@@ -689,7 +689,7 @@ void STAmount::canonicalize ()
}
if (mOffset > cMaxOffset)
throw std::runtime_error ("value overflow");
Throw<std::runtime_error> ("value overflow");
assert ((mValue == 0) || ((mValue >= cMinValue) && (mValue <= cMaxValue)));
assert ((mValue == 0) || ((mOffset >= cMinOffset) && (mOffset <= cMaxOffset)));
@@ -745,7 +745,7 @@ amountFromString (Issue const& issue, std::string const& amount)
boost::smatch match;
if (!boost::regex_match (amount, match, reNumber))
throw std::runtime_error ("Number '" + amount + "' is not valid");
Throw<std::runtime_error> ("Number '" + amount + "' is not valid");
// Match fields:
// 0 = whole input
@@ -759,13 +759,13 @@ amountFromString (Issue const& issue, std::string const& amount)
// CHECKME: Why 32? Shouldn't this be 16?
if ((match[2].length () + match[4].length ()) > 32)
throw std::runtime_error ("Number '" + amount + "' is overlong");
Throw<std::runtime_error> ("Number '" + amount + "' is overlong");
bool negative = (match[1].matched && (match[1] == "-"));
// Can't specify XRP using fractional representation
if (isXRP(issue) && match[3].matched)
throw std::runtime_error ("XRP must be specified in integral drops.");
Throw<std::runtime_error> ("XRP must be specified in integral drops.");
std::uint64_t mantissa;
int exponent;
@@ -831,7 +831,7 @@ amountFromJson (SField const& name, Json::Value const& v)
boost::split (elements, val, boost::is_any_of ("\t\n\r ,/"));
if (elements.size () > 3)
throw std::runtime_error ("invalid amount string");
Throw<std::runtime_error> ("invalid amount string");
value = elements[0];
@@ -853,21 +853,21 @@ amountFromJson (SField const& name, Json::Value const& v)
if (native)
{
if (v.isObject ())
throw std::runtime_error ("XRP may not be specified as an object");
Throw<std::runtime_error> ("XRP may not be specified as an object");
issue = xrpIssue ();
}
else
{
// non-XRP
if (! to_currency (issue.currency, currency.asString ()))
throw std::runtime_error ("invalid currency");
Throw<std::runtime_error> ("invalid currency");
if (! issuer.isString ()
|| !to_issuer (issue.account, issuer.asString ()))
throw std::runtime_error ("invalid issuer");
Throw<std::runtime_error> ("invalid issuer");
if (isXRP (issue.currency))
throw std::runtime_error ("invalid issuer");
Throw<std::runtime_error> ("invalid issuer");
}
if (value.isInt ())
@@ -896,7 +896,7 @@ amountFromJson (SField const& name, Json::Value const& v)
}
else
{
throw std::runtime_error ("invalid amount type");
Throw<std::runtime_error> ("invalid amount type");
}
return { name, issue, mantissa, exponent, native, negative };
@@ -937,7 +937,7 @@ bool
operator< (STAmount const& lhs, STAmount const& rhs)
{
if (!areComparable (lhs, rhs))
throw std::runtime_error ("Can't compare amounts that are't comparable!");
Throw<std::runtime_error> ("Can't compare amounts that are't comparable!");
if (lhs.negative() != rhs.negative())
return lhs.negative();
@@ -981,7 +981,7 @@ STAmount
divide (STAmount const& num, STAmount const& den, Issue const& issue)
{
if (den == zero)
throw std::runtime_error ("division by zero");
Throw<std::runtime_error> ("division by zero");
if (num == zero)
return {issue};
@@ -1017,7 +1017,7 @@ divide (STAmount const& num, STAmount const& den, Issue const& issue)
(BN_mul_word64 (&v, tenTo17) != 1) ||
(BN_div_word64 (&v, denVal) == ((std::uint64_t) - 1)))
{
throw std::runtime_error ("internal bn error");
Throw<std::runtime_error> ("internal bn error");
}
// 10^16 <= quotient <= 10^18
@@ -1043,10 +1043,10 @@ multiply (STAmount const& v1, STAmount const& v2, Issue const& issue)
? getSNValue (v2) : getSNValue (v1);
if (minV > 3000000000ull) // sqrt(cMaxNative)
throw std::runtime_error ("Native value overflow");
Throw<std::runtime_error> ("Native value overflow");
if (((maxV >> 32) * minV) > 2095475792ull) // cMaxNative / 2^32
throw std::runtime_error ("Native value overflow");
Throw<std::runtime_error> ("Native value overflow");
return STAmount (v1.getFName (), minV * maxV);
}
@@ -1082,7 +1082,7 @@ multiply (STAmount const& v1, STAmount const& v2, Issue const& issue)
(BN_mul_word64 (&v, value2) != 1) ||
(BN_div_word64 (&v, tenTo14) == ((std::uint64_t) - 1)))
{
throw std::runtime_error ("internal bn error");
Throw<std::runtime_error> ("internal bn error");
}
// 10^16 <= product <= 10^18
@@ -1153,10 +1153,10 @@ mulRound (STAmount const& v1, STAmount const& v2,
getSNValue (v2) : getSNValue (v1);
if (minV > 3000000000ull) // sqrt(cMaxNative)
throw std::runtime_error ("Native value overflow");
Throw<std::runtime_error> ("Native value overflow");
if (((maxV >> 32) * minV) > 2095475792ull) // cMaxNative / 2^32
throw std::runtime_error ("Native value overflow");
Throw<std::runtime_error> ("Native value overflow");
return STAmount (v1.getFName (), minV * maxV);
}
@@ -1188,13 +1188,13 @@ mulRound (STAmount const& v1, STAmount const& v2,
CBigNum v;
if ((BN_add_word64 (&v, value1) != 1) || (BN_mul_word64 (&v, value2) != 1))
throw std::runtime_error ("internal bn error");
Throw<std::runtime_error> ("internal bn error");
if (resultNegative != roundUp) // rounding down is automatic when we divide
BN_add_word64 (&v, tenTo14m1);
if (BN_div_word64 (&v, tenTo14) == ((std::uint64_t) - 1))
throw std::runtime_error ("internal bn error");
Throw<std::runtime_error> ("internal bn error");
// 10^16 <= product <= 10^18
assert (BN_num_bytes (&v) <= 64);
@@ -1211,7 +1211,7 @@ divRound (STAmount const& num, STAmount const& den,
Issue const& issue, bool roundUp)
{
if (den == zero)
throw std::runtime_error ("division by zero");
Throw<std::runtime_error> ("division by zero");
if (num == zero)
return {issue};
@@ -1239,13 +1239,13 @@ divRound (STAmount const& num, STAmount const& den,
CBigNum v;
if ((BN_add_word64 (&v, numVal) != 1) || (BN_mul_word64 (&v, tenTo17) != 1))
throw std::runtime_error ("internal bn error");
Throw<std::runtime_error> ("internal bn error");
if (resultNegative != roundUp) // Rounding down is automatic when we divide
BN_add_word64 (&v, denVal - 1);
if (BN_div_word64 (&v, denVal) == ((std::uint64_t) - 1))
throw std::runtime_error ("internal bn error");
Throw<std::runtime_error> ("internal bn error");
// 10^16 <= quotient <= 10^18
assert (BN_num_bytes (&v) <= 64);
@@ -1271,7 +1271,7 @@ mulDiv(std::uint64_t value, std::uint64_t mul, std::uint64_t div)
{
value /= div;
if (value > max / mul)
throw std::overflow_error("mulDiv");
Throw<std::overflow_error> ("mulDiv");
return value * mul;
}
return value * mul / div;

View File

@@ -18,6 +18,7 @@
//==============================================================================
#include <BeastConfig.h>
#include <ripple/basics/contract.h>
#include <ripple/basics/Log.h>
#include <ripple/protocol/STBase.h>
#include <ripple/protocol/STArray.h>
@@ -77,7 +78,7 @@ STArray::STArray (SerialIter& sit, SField const& f)
{
WriteLog (lsWARNING, STObject) <<
"Encountered array with end of object marker";
throw std::runtime_error ("Illegal terminator in array");
Throw<std::runtime_error> ("Illegal terminator in array");
}
auto const& fn = SField::getField (type, field);
@@ -86,13 +87,13 @@ STArray::STArray (SerialIter& sit, SField const& f)
{
WriteLog (lsTRACE, STObject) <<
"Unknown field: " << type << "/" << field;
throw std::runtime_error ("Unknown field");
Throw<std::runtime_error> ("Unknown field");
}
if (fn.fieldType != STI_OBJECT)
{
WriteLog (lsTRACE, STObject) << "Array contains non-object";
throw std::runtime_error ("Non-object in array");
Throw<std::runtime_error> ("Non-object in array");
}
v_.emplace_back(fn);
@@ -100,7 +101,7 @@ STArray::STArray (SerialIter& sit, SField const& f)
if (v_.back().setTypeFromSField (fn) == STObject::typeSetFail)
{
throw std::runtime_error ("Malformed object in array");
Throw<std::runtime_error> ("Malformed object in array");
}
}
}

View File

@@ -18,6 +18,7 @@
//==============================================================================
#include <BeastConfig.h>
#include <ripple/basics/contract.h>
#include <ripple/basics/Log.h>
#include <ripple/json/to_string.h>
#include <ripple/protocol/Indexes.h>
@@ -36,7 +37,7 @@ STLedgerEntry::STLedgerEntry (Keylet const& k)
mFormat =
LedgerFormats::getInstance().findByType (type_);
if (mFormat == nullptr)
throw std::runtime_error ("invalid ledger entry type");
Throw<std::runtime_error> ("invalid ledger entry type");
set (mFormat->elements);
setFieldU16 (sfLedgerEntryType,
static_cast <std::uint16_t> (mFormat->getType ()));
@@ -72,7 +73,7 @@ void STLedgerEntry::setSLEType ()
static_cast <LedgerEntryType> (getFieldU16 (sfLedgerEntryType)));
if (mFormat == nullptr)
throw std::runtime_error ("invalid ledger entry type");
Throw<std::runtime_error> ("invalid ledger entry type");
type_ = mFormat->getType ();
if (!setType (mFormat->elements))
@@ -80,7 +81,7 @@ void STLedgerEntry::setSLEType ()
WriteLog (lsWARNING, SerializedLedger)
<< "Ledger entry not valid for type " << mFormat->getName ();
WriteLog (lsWARNING, SerializedLedger) << getJson (0);
throw std::runtime_error ("ledger entry not valid for type");
Throw<std::runtime_error> ("ledger entry not valid for type");
}
}

View File

@@ -210,7 +210,7 @@ bool STObject::set (SerialIter& sit, int depth)
{
WriteLog (lsWARNING, STObject) <<
"Encountered object with end of array marker";
throw std::runtime_error ("Illegal terminator in object");
Throw<std::runtime_error> ("Illegal terminator in object");
}
if (!reachedEndOfObject)
@@ -224,7 +224,7 @@ bool STObject::set (SerialIter& sit, int depth)
WriteLog (lsWARNING, STObject) <<
"Unknown field: field_type=" << type <<
", field_name=" << field;
throw std::runtime_error ("Unknown field");
Throw<std::runtime_error> ("Unknown field");
}
// Unflatten the field
@@ -234,7 +234,7 @@ bool STObject::set (SerialIter& sit, int depth)
STObject* const obj = dynamic_cast <STObject*> (&(v_.back().get()));
if (obj && (obj->setTypeFromSField (fn) == typeSetFail))
{
throw std::runtime_error ("field deserialization error");
Throw<std::runtime_error> ("field deserialization error");
}
}
}
@@ -352,7 +352,7 @@ const STBase& STObject::peekAtField (SField const& field) const
int index = getFieldIndex (field);
if (index == -1)
throw std::runtime_error ("Field not found");
Throw<std::runtime_error> ("Field not found");
return peekAtIndex (index);
}
@@ -362,7 +362,7 @@ STBase& STObject::getField (SField const& field)
int index = getFieldIndex (field);
if (index == -1)
throw std::runtime_error ("Field not found");
Throw<std::runtime_error> ("Field not found");
return getIndex (index);
}
@@ -462,7 +462,7 @@ STBase* STObject::makeFieldPresent (SField const& field)
if (index == -1)
{
if (!isFree ())
throw std::runtime_error ("Field not found");
Throw<std::runtime_error> ("Field not found");
return getPIndex (emplace_back(detail::nonPresentObject, field));
}
@@ -482,7 +482,7 @@ void STObject::makeFieldAbsent (SField const& field)
int index = getFieldIndex (field);
if (index == -1)
throw std::runtime_error ("Field not found");
Throw<std::runtime_error> ("Field not found");
const STBase& f = peekAtIndex (index);
@@ -512,7 +512,7 @@ std::string STObject::getFieldString (SField const& field) const
{
const STBase* rf = peekAtPField (field);
if (!rf) throw std::runtime_error ("Field not found");
if (! rf) Throw<std::runtime_error> ("Field not found");
return rf->getText ();
}
@@ -606,7 +606,7 @@ STObject::set (std::unique_ptr<STBase> v)
else
{
if (! isFree())
throw std::runtime_error(
Throw<std::runtime_error> (
"missing field in templated STObject");
v_.emplace_back(std::move(*v));
}

View File

@@ -18,8 +18,8 @@
//==============================================================================
#include <BeastConfig.h>
#include <ripple/basics/contract.h>
#include <ripple/basics/StringUtilities.h>
#include <ripple/protocol/STInteger.h>
#include <ripple/protocol/ErrorCodes.h>
#include <ripple/protocol/LedgerFormats.h>
#include <ripple/protocol/STAccount.h>
@@ -28,6 +28,7 @@
#include <ripple/protocol/STBitString.h>
#include <ripple/protocol/STBlob.h>
#include <ripple/protocol/STVector256.h>
#include <ripple/protocol/STInteger.h>
#include <ripple/protocol/STParsedJSON.h>
#include <ripple/protocol/STPathSet.h>
#include <ripple/protocol/TxFormats.h>
@@ -46,7 +47,7 @@ template <typename T, typename U>
static T range_check_cast (U value, T minimum, T maximum)
{
if ((value < minimum) || (value > maximum))
throw std::runtime_error ("Value out of range");
Throw<std::runtime_error> ("Value out of range");
return static_cast<T> (value);
}
@@ -212,7 +213,7 @@ static boost::optional<detail::STVar> parseLeaf (
return ret;
}
}
catch (...)
catch (std::exception const&)
{
error = invalid_data (json_name, fieldName);
return ret;
@@ -282,7 +283,7 @@ static boost::optional<detail::STVar> parseLeaf (
return ret;
}
}
catch (...)
catch (std::exception const&)
{
error = invalid_data (json_name, fieldName);
return ret;
@@ -316,7 +317,7 @@ static boost::optional<detail::STVar> parseLeaf (
return ret;
}
}
catch (...)
catch (std::exception const&)
{
error = invalid_data (json_name, fieldName);
return ret;
@@ -349,7 +350,7 @@ static boost::optional<detail::STVar> parseLeaf (
return ret;
}
}
catch (...)
catch (std::exception const&)
{
error = invalid_data (json_name, fieldName);
return ret;
@@ -370,7 +371,7 @@ static boost::optional<detail::STVar> parseLeaf (
return ret;
}
}
catch (...)
catch (std::exception const&)
{
error = invalid_data (json_name, fieldName);
return ret;
@@ -391,7 +392,7 @@ static boost::optional<detail::STVar> parseLeaf (
return ret;
}
}
catch (...)
catch (std::exception const&)
{
error = invalid_data (json_name, fieldName);
return ret;
@@ -412,7 +413,7 @@ static boost::optional<detail::STVar> parseLeaf (
return ret;
}
}
catch (...)
catch (std::exception const&)
{
error = invalid_data (json_name, fieldName);
return ret;
@@ -431,13 +432,13 @@ static boost::optional<detail::STVar> parseLeaf (
{
std::pair<Blob, bool> vBlob (strUnHex (value.asString ()));
if (!vBlob.second)
throw std::invalid_argument ("invalid data");
if (! vBlob.second)
Throw<std::invalid_argument> ("invalid data");
ret = detail::make_stvar <STBlob> (field, vBlob.first.data (),
vBlob.first.size ());
}
catch (...)
catch (std::exception const&)
{
error = invalid_data (json_name, fieldName);
return ret;
@@ -450,7 +451,7 @@ static boost::optional<detail::STVar> parseLeaf (
{
ret = detail::make_stvar <STAmount> (amountFromJson (field, value));
}
catch (...)
catch (std::exception const&)
{
error = invalid_data (json_name, fieldName);
return ret;
@@ -476,7 +477,7 @@ static boost::optional<detail::STVar> parseLeaf (
}
ret = detail::make_stvar <STVector256> (std::move (tail));
}
catch (...)
catch (std::exception const&)
{
error = invalid_data (json_name, fieldName);
return ret;
@@ -606,7 +607,7 @@ static boost::optional<detail::STVar> parseLeaf (
}
ret = detail::make_stvar <STPathSet> (std::move (tail));
}
catch (...)
catch (std::exception const&)
{
error = invalid_data (json_name, fieldName);
return ret;
@@ -638,7 +639,7 @@ static boost::optional<detail::STVar> parseLeaf (
ret = detail::make_stvar <STAccount>(
field, *account);
}
catch (...)
catch (std::exception const&)
{
error = invalid_data (json_name, fieldName);
return ret;
@@ -721,7 +722,7 @@ static boost::optional <STObject> parseObject (
return boost::none;
data.emplace_back (std::move (*ret));
}
catch (...)
catch (std::exception const&)
{
error = invalid_data (json_name, fieldName);
return boost::none;
@@ -739,7 +740,7 @@ static boost::optional <STObject> parseObject (
return boost::none;
data.emplace_back (std::move (*array));
}
catch (...)
catch (std::exception const&)
{
error = invalid_data (json_name, fieldName);
return boost::none;
@@ -846,7 +847,7 @@ static boost::optional <detail::STVar> parseArray (
return detail::make_stvar <STArray> (std::move (tail));
}
catch (...)
catch (std::exception const&)
{
error = invalid_data (json_name);
return boost::none;

View File

@@ -20,6 +20,7 @@
#include <BeastConfig.h>
#include <ripple/protocol/STPathSet.h>
#include <ripple/protocol/JsonFields.h>
#include <ripple/basics/contract.h>
#include <ripple/basics/Log.h>
#include <ripple/basics/strHex.h>
#include <ripple/basics/StringUtilities.h>
@@ -65,7 +66,7 @@ STPathSet::STPathSet (SerialIter& sit, SField const& name)
{
WriteLog (lsINFO, STBase)
<< "STPathSet: Empty path.";
throw std::runtime_error ("empty path");
Throw<std::runtime_error> ("empty path");
}
push_back (path);
@@ -79,7 +80,7 @@ STPathSet::STPathSet (SerialIter& sit, SField const& name)
WriteLog (lsINFO, STBase)
<< "STPathSet: Bad path element: " << iType;
throw std::runtime_error ("bad path element");
Throw<std::runtime_error> ("bad path element");
}
else
{

View File

@@ -49,7 +49,7 @@ STTx::STTx (TxType type)
{
WriteLog (lsWARNING, STTx) <<
"Transaction type: " << type;
throw std::runtime_error ("invalid transaction type");
Throw<std::runtime_error> ("invalid transaction type");
}
set (format->elements);
@@ -67,14 +67,14 @@ STTx::STTx (STObject&& object)
{
WriteLog (lsWARNING, STTx) <<
"Transaction type: " << tx_type_;
throw std::runtime_error ("invalid transaction type");
Throw<std::runtime_error> ("invalid transaction type");
}
if (!setType (format->elements))
{
WriteLog (lsWARNING, STTx) <<
"Transaction not legal for format";
throw std::runtime_error ("transaction not valid");
Throw<std::runtime_error> ("transaction not valid");
}
tid_ = getHash(HashPrefix::transactionID);
@@ -89,7 +89,7 @@ STTx::STTx (SerialIter& sit)
{
WriteLog (lsERROR, STTx) <<
"Transaction has invalid length: " << length;
throw std::runtime_error ("Transaction length invalid");
Throw<std::runtime_error> ("Transaction length invalid");
}
set (sit);
@@ -101,14 +101,14 @@ STTx::STTx (SerialIter& sit)
{
WriteLog (lsWARNING, STTx) <<
"Invalid transaction type: " << tx_type_;
throw std::runtime_error ("invalid transaction type");
Throw<std::runtime_error> ("invalid transaction type");
}
if (!setType (format->elements))
{
WriteLog (lsWARNING, STTx) <<
"Transaction not legal for format";
throw std::runtime_error ("transaction not valid");
Throw<std::runtime_error> ("transaction not valid");
}
tid_ = getHash(HashPrefix::transactionID);
@@ -178,7 +178,7 @@ Blob STTx::getSignature () const
{
return getFieldVL (sfTxnSignature);
}
catch (...)
catch (std::exception const&)
{
return Blob ();
}
@@ -210,7 +210,7 @@ bool STTx::checkSign(bool allowMultiSign) const
sigGood = checkSingleSign ();
}
}
catch (...)
catch (std::exception const&)
{
}
return sigGood;
@@ -298,7 +298,7 @@ STTx::checkSingleSign () const
ret = n.accountPublicVerify (getSigningData (*this),
getFieldVL (sfTxnSignature), fullyCanonical);
}
catch (...)
catch (std::exception const&)
{
// Assume it was a signature failure.
ret = false;
@@ -372,7 +372,7 @@ STTx::checkMultiSign () const
validSig = pubKey.accountPublicVerify (
s.getData(), signature, fullyCanonical);
}
catch (...)
catch (std::exception const&)
{
// We assume any problem lies with the signature.
validSig = false;

View File

@@ -20,6 +20,7 @@
#include <BeastConfig.h>
#include <ripple/protocol/STValidation.h>
#include <ripple/protocol/HashPrefix.h>
#include <ripple/basics/contract.h>
#include <ripple/basics/Log.h>
#include <ripple/json/to_string.h>
@@ -35,7 +36,7 @@ STValidation::STValidation (SerialIter& sit, bool checkSignature)
if (checkSignature && !isValid ())
{
WriteLog (lsTRACE, Ledger) << "Invalid validation " << getJson (0);
throw std::runtime_error ("Invalid validation");
Throw<std::runtime_error> ("Invalid validation");
}
}
@@ -104,7 +105,7 @@ bool STValidation::isValid (uint256 const& signingHash) const
return raPublicKey.isValid () &&
raPublicKey.verifyNodePublic (signingHash, getFieldVL (sfSignature), fullyCanonical);
}
catch (...)
catch (std::exception const&)
{
WriteLog (lsINFO, Ledger) << "exception validating validation";
return false;

View File

@@ -18,6 +18,7 @@
//==============================================================================
#include <BeastConfig.h>
#include <ripple/basics/contract.h>
#include <ripple/protocol/STAccount.h>
#include <ripple/protocol/STAmount.h>
#include <ripple/protocol/STArray.h>
@@ -142,7 +143,7 @@ STVar::STVar (SerialIter& sit, SField const& name)
case STI_OBJECT: construct<STObject>(sit, name); return;
case STI_ARRAY: construct<STArray>(sit, name); return;
default:
throw std::runtime_error ("Unknown object type");
Throw<std::runtime_error> ("Unknown object type");
}
}
@@ -167,7 +168,7 @@ STVar::STVar (SerializedTypeID id, SField const& name)
case STI_OBJECT: construct<STObject>(name); return;
case STI_ARRAY: construct<STArray>(name); return;
default:
throw std::runtime_error ("Unknown object type");
Throw<std::runtime_error> ("Unknown object type");
}
}

View File

@@ -18,6 +18,7 @@
//==============================================================================
#include <BeastConfig.h>
#include <ripple/basics/contract.h>
#include <ripple/basics/Log.h>
#include <ripple/protocol/digest.h>
#include <ripple/protocol/Serializer.h>
@@ -283,7 +284,7 @@ bool Serializer::getVL (Blob& objectVL, int offset, int& length) const
}
else return false;
}
catch (...)
catch (std::exception const&)
{
return false;
}
@@ -324,7 +325,7 @@ bool Serializer::getVLLength (int& length, int offset) const
}
else return false;
}
catch (...)
catch (std::exception const&)
{
return false;
}
@@ -357,14 +358,14 @@ int Serializer::addEncoded (int length)
bytes[2] = static_cast<unsigned char> (length & 0xff);
numBytes = 3;
}
else throw std::overflow_error ("lenlen");
else Throw<std::overflow_error> ("lenlen");
return addRaw (&bytes[0], numBytes);
}
int Serializer::encodeLengthLength (int length)
{
if (length < 0) throw std::overflow_error ("len<0");
if (length < 0) Throw<std::overflow_error> ("len<0");
if (length <= 192) return 1;
@@ -372,12 +373,13 @@ int Serializer::encodeLengthLength (int length)
if (length <= 918744) return 3;
throw std::overflow_error ("len>918744");
Throw<std::overflow_error> ("len>918744");
return 0; // Silence compiler warning.
}
int Serializer::decodeLengthLength (int b1)
{
if (b1 < 0) throw std::overflow_error ("b1<0");
if (b1 < 0) Throw<std::overflow_error> ("b1<0");
if (b1 <= 192) return 1;
@@ -385,32 +387,33 @@ int Serializer::decodeLengthLength (int b1)
if (b1 <= 254) return 3;
throw std::overflow_error ("b1>254");
Throw<std::overflow_error> ("b1>254");
return 0; // Silence compiler warning.
}
int Serializer::decodeVLLength (int b1)
{
if (b1 < 0) throw std::overflow_error ("b1<0");
if (b1 < 0) Throw<std::overflow_error> ("b1<0");
if (b1 > 254) throw std::overflow_error ("b1>254");
if (b1 > 254) Throw<std::overflow_error> ("b1>254");
return b1;
}
int Serializer::decodeVLLength (int b1, int b2)
{
if (b1 < 193) throw std::overflow_error ("b1<193");
if (b1 < 193) Throw<std::overflow_error> ("b1<193");
if (b1 > 240) throw std::overflow_error ("b1>240");
if (b1 > 240) Throw<std::overflow_error> ("b1>240");
return 193 + (b1 - 193) * 256 + b2;
}
int Serializer::decodeVLLength (int b1, int b2, int b3)
{
if (b1 < 241) throw std::overflow_error ("b1<241");
if (b1 < 241) Throw<std::overflow_error> ("b1<241");
if (b1 > 254) throw std::overflow_error ("b1>254");
if (b1 > 254) Throw<std::overflow_error> ("b1>254");
return 12481 + (b1 - 241) * 65536 + b2 * 256 + b3;
}
@@ -448,7 +451,7 @@ unsigned char
SerialIter::get8()
{
if (remain_ < 1)
throw std::runtime_error(
Throw<std::runtime_error> (
"invalid SerialIter get8");
unsigned char t = *p_;
++p_;
@@ -461,7 +464,7 @@ std::uint16_t
SerialIter::get16()
{
if (remain_ < 2)
throw std::runtime_error(
Throw<std::runtime_error> (
"invalid SerialIter get16");
auto t = p_;
p_ += 2;
@@ -476,7 +479,7 @@ std::uint32_t
SerialIter::get32()
{
if (remain_ < 4)
throw std::runtime_error(
Throw<std::runtime_error> (
"invalid SerialIter get32");
auto t = p_;
p_ += 4;
@@ -493,7 +496,7 @@ std::uint64_t
SerialIter::get64 ()
{
if (remain_ < 8)
throw std::runtime_error(
Throw<std::runtime_error> (
"invalid SerialIter get64");
auto t = p_;
p_ += 8;
@@ -522,7 +525,7 @@ SerialIter::getFieldID (int& type, int& name)
// uncommon type
type = get8();
if (type == 0 || type < 16)
throw std::runtime_error(
Throw<std::runtime_error> (
"gFID: uncommon type out of range " +
std::to_string(type));
}
@@ -532,7 +535,7 @@ SerialIter::getFieldID (int& type, int& name)
// uncommon name
name = get8();
if (name == 0 || name < 16)
throw std::runtime_error(
Throw<std::runtime_error> (
"gFID: uncommon name out of range " +
std::to_string(name));
}
@@ -545,7 +548,7 @@ T SerialIter::getRawHelper (int size)
static_assert(std::is_same<T, Blob>::value ||
std::is_same<T, Buffer>::value, "");
if (remain_ < size)
throw std::runtime_error(
Throw<std::runtime_error> (
"invalid SerialIter getRaw");
T result (size);
memcpy(result.data (), p_, size);
@@ -590,7 +593,7 @@ Slice
SerialIter::getSlice (std::size_t bytes)
{
if (bytes > remain_)
throw std::runtime_error(
Throw<std::runtime_error> (
"invalid SerialIter getSlice");
Slice s(p_, bytes);
p_ += bytes;

View File

@@ -18,6 +18,7 @@
//==============================================================================
#include <BeastConfig.h>
#include <ripple/basics/contract.h>
#include <ripple/protocol/InnerObjectFormats.h>
#include <ripple/protocol/ErrorCodes.h> // RPC::containsError
#include <ripple/json/json_reader.h> // Json::Reader
@@ -180,7 +181,7 @@ public:
Json::Reader ().parse (test.txt, req);
if (RPC::contains_error (req))
{
throw std::runtime_error (
Throw<std::runtime_error> (
"Internal InnerObjectFormatsParsedJSON error. Bad JSON.");
}
STParsedJSONObject parsed ("request", req);

View File

@@ -593,7 +593,7 @@ public:
{
pass ();
}
catch (...)
catch (std::exception const&)
{
fail ("wrong exception");
}
@@ -625,7 +625,7 @@ public:
{
pass ();
}
catch (...)
catch (std::exception const&)
{
fail ("wrong exception");
}

View File

@@ -152,7 +152,7 @@ public:
STTx copy (sit);
serialized = true;
}
catch (...)
catch (std::exception const&)
{
; // If it threw then serialization failed.
}