aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorJack Lloyd <lloyd@randombit.net>2015-12-19 16:09:17 -0500
committerJack Lloyd <lloyd@randombit.net>2015-12-19 16:09:17 -0500
commit0fae1884079518e4f6d1c049cc7f341cd96c8a65 (patch)
tree41e3a8aea10b7381c0e2cfd4ee019745215876ac /src/lib
parentb3da432772628fdb3eed9cf5dabb54eda0097d2b (diff)
Remove all remaining uses of throwing a std:: exception directly
See GH #340 and 6b9a3a5 for background
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/base/scan_name.cpp2
-rw-r--r--src/lib/compression/bzip2/bzip2.cpp12
-rw-r--r--src/lib/compression/lzma/lzma.cpp6
-rw-r--r--src/lib/compression/zlib/zlib.cpp6
-rw-r--r--src/lib/misc/fpe_fe1/fpe_fe1.cpp2
-rw-r--r--src/lib/pubkey/mce/gf2m_rootfind_dcmp.cpp3
-rw-r--r--src/lib/tls/tls_policy.cpp2
7 files changed, 17 insertions, 16 deletions
diff --git a/src/lib/base/scan_name.cpp b/src/lib/base/scan_name.cpp
index 6f5eac43c..2b32dc7d3 100644
--- a/src/lib/base/scan_name.cpp
+++ b/src/lib/base/scan_name.cpp
@@ -155,7 +155,7 @@ std::string SCAN_Name::all_arguments() const
std::string SCAN_Name::arg(size_t i) const
{
if(i >= arg_count())
- throw std::range_error("SCAN_Name::arg " + std::to_string(i) +
+ throw Invalid_Argument("SCAN_Name::arg " + std::to_string(i) +
" out of range for '" + as_string() + "'");
return args[i];
}
diff --git a/src/lib/compression/bzip2/bzip2.cpp b/src/lib/compression/bzip2/bzip2.cpp
index d7527bfef..09cd05919 100644
--- a/src/lib/compression/bzip2/bzip2.cpp
+++ b/src/lib/compression/bzip2/bzip2.cpp
@@ -42,7 +42,7 @@ class Bzip2_Compression_Stream : public Bzip2_Stream
int rc = BZ2_bzCompressInit(streamp(), block_size, 0, 0);
if(rc == BZ_MEM_ERROR)
- throw std::bad_alloc();
+ throw Exception("bzip memory allocation failure");
else if(rc != BZ_OK)
throw Exception("bzip compress initialization failed");
}
@@ -57,9 +57,9 @@ class Bzip2_Compression_Stream : public Bzip2_Stream
int rc = BZ2_bzCompress(streamp(), flags);
if(rc == BZ_MEM_ERROR)
- throw std::bad_alloc();
+ throw Exception("bzip memory allocation failure");
else if(rc < 0)
- throw Exception("bzip compress error");
+ throw Exception("bzip compress error " + std::to_string(-rc));
return (rc == BZ_STREAM_END);
}
@@ -73,7 +73,7 @@ class Bzip2_Decompression_Stream : public Bzip2_Stream
int rc = BZ2_bzDecompressInit(streamp(), 0, 0);
if(rc == BZ_MEM_ERROR)
- throw std::bad_alloc();
+ throw Exception("bzip memory allocation failure");
else if(rc != BZ_OK)
throw Exception("bzip decompress initialization failed");
}
@@ -88,9 +88,9 @@ class Bzip2_Decompression_Stream : public Bzip2_Stream
int rc = BZ2_bzDecompress(streamp());
if(rc == BZ_MEM_ERROR)
- throw std::bad_alloc();
+ throw Exception("bzip memory allocation failure");
else if(rc != BZ_OK && rc != BZ_STREAM_END)
- throw Exception("bzip decompress error");
+ throw Exception("bzip decompress error " + std::to_string(-rc));
return (rc == BZ_STREAM_END);
}
diff --git a/src/lib/compression/lzma/lzma.cpp b/src/lib/compression/lzma/lzma.cpp
index 6e5217767..5998d1c8c 100644
--- a/src/lib/compression/lzma/lzma.cpp
+++ b/src/lib/compression/lzma/lzma.cpp
@@ -41,7 +41,7 @@ class LZMA_Stream : public Zlib_Style_Stream<lzma_stream, byte>
lzma_ret rc = ::lzma_code(streamp(), static_cast<lzma_action>(flags));
if(rc == LZMA_MEM_ERROR)
- throw std::bad_alloc();
+ throw Exception("lzma memory allocation failed");
else if (rc != LZMA_OK && rc != LZMA_STREAM_END)
throw Exception("Lzma error");
@@ -61,7 +61,7 @@ class LZMA_Compression_Stream : public LZMA_Stream
lzma_ret rc = ::lzma_easy_encoder(streamp(), level, LZMA_CHECK_CRC64);
if(rc == LZMA_MEM_ERROR)
- throw std::bad_alloc();
+ throw Exception("lzma memory allocation failed");
else if(rc != LZMA_OK)
throw Exception("lzma compress initialization failed");
}
@@ -76,7 +76,7 @@ class LZMA_Decompression_Stream : public LZMA_Stream
LZMA_TELL_UNSUPPORTED_CHECK);
if(rc == LZMA_MEM_ERROR)
- throw std::bad_alloc();
+ throw Exception("lzma memory allocation failed");
else if(rc != LZMA_OK)
throw Exception("Bad setting in lzma_stream_decoder");
}
diff --git a/src/lib/compression/zlib/zlib.cpp b/src/lib/compression/zlib/zlib.cpp
index 10422fff7..8e1928826 100644
--- a/src/lib/compression/zlib/zlib.cpp
+++ b/src/lib/compression/zlib/zlib.cpp
@@ -66,7 +66,7 @@ class Zlib_Compression_Stream : public Zlib_Stream
int rc = deflate(streamp(), flags);
if(rc == Z_MEM_ERROR)
- throw std::bad_alloc();
+ throw Exception("zlib memory allocation failure");
else if(rc != Z_OK && rc != Z_STREAM_END && rc != Z_BUF_ERROR)
throw Exception("zlib deflate error " + std::to_string(rc));
@@ -82,7 +82,7 @@ class Zlib_Decompression_Stream : public Zlib_Stream
int rc = inflateInit2(streamp(), compute_window_bits(wbits, wbits_offset));
if(rc == Z_MEM_ERROR)
- throw std::bad_alloc();
+ throw Exception("zlib memory allocation failure");
else if(rc != Z_OK)
throw Exception("zlib inflate initialization failed");
}
@@ -97,7 +97,7 @@ class Zlib_Decompression_Stream : public Zlib_Stream
int rc = inflate(streamp(), flags);
if(rc == Z_MEM_ERROR)
- throw std::bad_alloc();
+ throw Exception("zlib memory allocation failure");
else if(rc != Z_OK && rc != Z_STREAM_END && rc != Z_BUF_ERROR)
throw Exception("zlib inflate error " + std::to_string(rc));
diff --git a/src/lib/misc/fpe_fe1/fpe_fe1.cpp b/src/lib/misc/fpe_fe1/fpe_fe1.cpp
index fad17c814..197dbb21a 100644
--- a/src/lib/misc/fpe_fe1/fpe_fe1.cpp
+++ b/src/lib/misc/fpe_fe1/fpe_fe1.cpp
@@ -68,7 +68,7 @@ void factor(BigInt n, BigInt& a, BigInt& b)
size_t rounds(const BigInt& a, const BigInt& b)
{
if(a < b)
- throw std::logic_error("FPE rounds: a < b");
+ throw Internal_Error("FPE rounds: a < b");
return 3;
}
diff --git a/src/lib/pubkey/mce/gf2m_rootfind_dcmp.cpp b/src/lib/pubkey/mce/gf2m_rootfind_dcmp.cpp
index d23d05172..3a377a447 100644
--- a/src/lib/pubkey/mce/gf2m_rootfind_dcmp.cpp
+++ b/src/lib/pubkey/mce/gf2m_rootfind_dcmp.cpp
@@ -9,6 +9,7 @@
#include <botan/polyn_gf2m.h>
#include <botan/internal/bit_ops.h>
#include <botan/internal/code_based_util.h>
+#include <botan/exceptn.h>
namespace Botan {
@@ -102,7 +103,7 @@ gf2m_decomp_rootfind_state::gf2m_decomp_rootfind_state(const polyn_gf2m & polyn,
int deg_sigma = polyn.get_degree();
if(deg_sigma <= 3)
{
- throw std::exception();
+ throw Internal_Error("Unexpected degree in gf2m_decomp_rootfind_state");
}
this->m_j = 0;
coeff_3 = polyn.get_coef( 3);
diff --git a/src/lib/tls/tls_policy.cpp b/src/lib/tls/tls_policy.cpp
index 7d1af71ef..374c5f12b 100644
--- a/src/lib/tls/tls_policy.cpp
+++ b/src/lib/tls/tls_policy.cpp
@@ -306,7 +306,7 @@ std::vector<u16bit> Policy::ciphersuite_list(Protocol_Version version,
}
if(ciphersuites.empty())
- throw std::logic_error("Policy does not allow any available cipher suite");
+ throw Exception("Policy does not allow any available cipher suite");
std::vector<u16bit> ciphersuite_codes;
for(auto i : ciphersuites)