mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Replace custom exceptions with std::runtime_error
This commit is contained in:
@@ -22,10 +22,12 @@
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <ripple/crypto/bignum_error.h>
|
||||
#include <ripple/crypto/CBigNum.h>
|
||||
#include <ripple/crypto/CAutoBN_CTX.h>
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
CBigNum::CBigNum ()
|
||||
@@ -40,14 +42,14 @@ CBigNum::CBigNum (const CBigNum& b)
|
||||
if (!BN_copy (this, &b))
|
||||
{
|
||||
BN_clear_free (this);
|
||||
throw bignum_error ("CBigNum::CBigNum(const CBigNum&) : BN_copy failed");
|
||||
throw std::runtime_error ("CBigNum::CBigNum(const CBigNum&) : BN_copy failed");
|
||||
}
|
||||
}
|
||||
|
||||
CBigNum& CBigNum::operator= (const CBigNum& b)
|
||||
{
|
||||
if (!BN_copy (this, &b))
|
||||
throw bignum_error ("CBigNum::operator= : BN_copy failed");
|
||||
throw std::runtime_error ("CBigNum::operator= : BN_copy failed");
|
||||
|
||||
return (*this);
|
||||
}
|
||||
@@ -378,7 +380,7 @@ std::string CBigNum::ToString (int nBase) const
|
||||
while (BN_cmp (&bn, &bn0) > 0)
|
||||
{
|
||||
if (!BN_div (&dv, &rem, &bn, &bnBase, pctx))
|
||||
throw bignum_error ("CBigNum::ToString() : BN_div failed");
|
||||
throw std::runtime_error ("CBigNum::ToString() : BN_div failed");
|
||||
|
||||
bn = dv;
|
||||
unsigned int c = rem.getuint ();
|
||||
@@ -405,7 +407,7 @@ bool CBigNum::operator! () const
|
||||
CBigNum& CBigNum::operator+= (const CBigNum& b)
|
||||
{
|
||||
if (!BN_add (this, this, &b))
|
||||
throw bignum_error ("CBigNum::operator+= : BN_add failed");
|
||||
throw std::runtime_error ("CBigNum::operator+= : BN_add failed");
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -421,7 +423,7 @@ CBigNum& CBigNum::operator*= (const CBigNum& b)
|
||||
CAutoBN_CTX pctx;
|
||||
|
||||
if (!BN_mul (this, this, &b, pctx))
|
||||
throw bignum_error ("CBigNum::operator*= : BN_mul failed");
|
||||
throw std::runtime_error ("CBigNum::operator*= : BN_mul failed");
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -441,7 +443,7 @@ CBigNum& CBigNum::operator%= (const CBigNum& b)
|
||||
CBigNum& CBigNum::operator<<= (unsigned int shift)
|
||||
{
|
||||
if (!BN_lshift (this, this, shift))
|
||||
throw bignum_error ("CBigNum:operator<<= : BN_lshift failed");
|
||||
throw std::runtime_error ("CBigNum:operator<<= : BN_lshift failed");
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -460,7 +462,7 @@ CBigNum& CBigNum::operator>>= (unsigned int shift)
|
||||
}
|
||||
|
||||
if (!BN_rshift (this, this, shift))
|
||||
throw bignum_error ("CBigNum:operator>>= : BN_rshift failed");
|
||||
throw std::runtime_error ("CBigNum:operator>>= : BN_rshift failed");
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -470,7 +472,7 @@ CBigNum& CBigNum::operator++ ()
|
||||
{
|
||||
// prefix operator
|
||||
if (!BN_add (this, this, BN_value_one ()))
|
||||
throw bignum_error ("CBigNum::operator++ : BN_add failed");
|
||||
throw std::runtime_error ("CBigNum::operator++ : BN_add failed");
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -489,7 +491,7 @@ CBigNum& CBigNum::operator-- ()
|
||||
CBigNum r;
|
||||
|
||||
if (!BN_sub (&r, this, BN_value_one ()))
|
||||
throw bignum_error ("CBigNum::operator-- : BN_sub failed");
|
||||
throw std::runtime_error ("CBigNum::operator-- : BN_sub failed");
|
||||
|
||||
*this = r;
|
||||
return *this;
|
||||
@@ -506,7 +508,7 @@ const CBigNum CBigNum::operator-- (int)
|
||||
void CBigNum::setulong (unsigned long n)
|
||||
{
|
||||
if (!BN_set_word (this, n))
|
||||
throw bignum_error ("CBigNum conversion from unsigned long : BN_set_word failed");
|
||||
throw std::runtime_error ("CBigNum conversion from unsigned long : BN_set_word failed");
|
||||
}
|
||||
|
||||
unsigned long CBigNum::getulong () const
|
||||
@@ -519,7 +521,7 @@ const CBigNum operator+ (const CBigNum& a, const CBigNum& b)
|
||||
CBigNum r;
|
||||
|
||||
if (!BN_add (&r, &a, &b))
|
||||
throw bignum_error ("CBigNum::operator+ : BN_add failed");
|
||||
throw std::runtime_error ("CBigNum::operator+ : BN_add failed");
|
||||
|
||||
return r;
|
||||
}
|
||||
@@ -529,7 +531,7 @@ const CBigNum operator- (const CBigNum& a, const CBigNum& b)
|
||||
CBigNum r;
|
||||
|
||||
if (!BN_sub (&r, &a, &b))
|
||||
throw bignum_error ("CBigNum::operator- : BN_sub failed");
|
||||
throw std::runtime_error ("CBigNum::operator- : BN_sub failed");
|
||||
|
||||
return r;
|
||||
}
|
||||
@@ -547,7 +549,7 @@ const CBigNum operator* (const CBigNum& a, const CBigNum& b)
|
||||
CBigNum r;
|
||||
|
||||
if (!BN_mul (&r, &a, &b, pctx))
|
||||
throw bignum_error ("CBigNum::operator* : BN_mul failed");
|
||||
throw std::runtime_error ("CBigNum::operator* : BN_mul failed");
|
||||
|
||||
return r;
|
||||
}
|
||||
@@ -558,7 +560,7 @@ const CBigNum operator/ (const CBigNum& a, const CBigNum& b)
|
||||
CBigNum r;
|
||||
|
||||
if (!BN_div (&r, nullptr, &a, &b, pctx))
|
||||
throw bignum_error ("CBigNum::operator/ : BN_div failed");
|
||||
throw std::runtime_error ("CBigNum::operator/ : BN_div failed");
|
||||
|
||||
return r;
|
||||
}
|
||||
@@ -569,7 +571,7 @@ const CBigNum operator% (const CBigNum& a, const CBigNum& b)
|
||||
CBigNum r;
|
||||
|
||||
if (!BN_mod (&r, &a, &b, pctx))
|
||||
throw bignum_error ("CBigNum::operator% : BN_div failed");
|
||||
throw std::runtime_error ("CBigNum::operator% : BN_div failed");
|
||||
|
||||
return r;
|
||||
}
|
||||
@@ -579,7 +581,7 @@ const CBigNum operator<< (const CBigNum& a, unsigned int shift)
|
||||
CBigNum r;
|
||||
|
||||
if (!BN_lshift (&r, &a, shift))
|
||||
throw bignum_error ("CBigNum:operator<< : BN_lshift failed");
|
||||
throw std::runtime_error ("CBigNum:operator<< : BN_lshift failed");
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/crypto/CKey.h>
|
||||
#include <ripple/crypto/ECIES.h>
|
||||
#include <ripple/crypto/RandomNumbers.h>
|
||||
#include <openssl/ec.h>
|
||||
|
||||
Reference in New Issue
Block a user