diff options
author | Jack Lloyd <[email protected]> | 2015-12-11 09:42:06 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2015-12-11 09:42:06 -0500 |
commit | 6b9a3a534071ef84c121c406559f8fc7ad546104 (patch) | |
tree | c11480ad1f07e443ba4e992fefcd618b532c2e93 /src/lib/compression | |
parent | 79a51627ee11f4d7f55d589751b30463d1f02a76 (diff) |
Reroot the exception hierarchy into a toplevel Exception class
As the alternatives are unfortunate for applications trying to catch
all library errors, and it seems deriving from std::runtime_error
causes problems with MSVC DLLs (GH #340)
Effectively reverts 2837e915d82e43
Diffstat (limited to 'src/lib/compression')
-rw-r--r-- | src/lib/compression/bzip2/bzip2.cpp | 8 | ||||
-rw-r--r-- | src/lib/compression/compression.cpp | 6 | ||||
-rw-r--r-- | src/lib/compression/compression.h | 2 | ||||
-rw-r--r-- | src/lib/compression/lzma/lzma.cpp | 6 | ||||
-rw-r--r-- | src/lib/compression/zlib/zlib.cpp | 10 |
5 files changed, 16 insertions, 16 deletions
diff --git a/src/lib/compression/bzip2/bzip2.cpp b/src/lib/compression/bzip2/bzip2.cpp index 857af10b1..d7527bfef 100644 --- a/src/lib/compression/bzip2/bzip2.cpp +++ b/src/lib/compression/bzip2/bzip2.cpp @@ -44,7 +44,7 @@ class Bzip2_Compression_Stream : public Bzip2_Stream if(rc == BZ_MEM_ERROR) throw std::bad_alloc(); else if(rc != BZ_OK) - throw std::runtime_error("bzip compress initialization failed"); + throw Exception("bzip compress initialization failed"); } ~Bzip2_Compression_Stream() @@ -59,7 +59,7 @@ class Bzip2_Compression_Stream : public Bzip2_Stream if(rc == BZ_MEM_ERROR) throw std::bad_alloc(); else if(rc < 0) - throw std::runtime_error("bzip compress error"); + throw Exception("bzip compress error"); return (rc == BZ_STREAM_END); } @@ -75,7 +75,7 @@ class Bzip2_Decompression_Stream : public Bzip2_Stream if(rc == BZ_MEM_ERROR) throw std::bad_alloc(); else if(rc != BZ_OK) - throw std::runtime_error("bzip decompress initialization failed"); + throw Exception("bzip decompress initialization failed"); } ~Bzip2_Decompression_Stream() @@ -90,7 +90,7 @@ class Bzip2_Decompression_Stream : public Bzip2_Stream if(rc == BZ_MEM_ERROR) throw std::bad_alloc(); else if(rc != BZ_OK && rc != BZ_STREAM_END) - throw std::runtime_error("bzip decompress error"); + throw Exception("bzip decompress error"); return (rc == BZ_STREAM_END); } diff --git a/src/lib/compression/compression.cpp b/src/lib/compression/compression.cpp index ddbcd7cec..fc2c6192a 100644 --- a/src/lib/compression/compression.cpp +++ b/src/lib/compression/compression.cpp @@ -28,7 +28,7 @@ void Compression_Alloc_Info::do_free(void* ptr) auto i = m_current_allocs.find(ptr); if(i == m_current_allocs.end()) - throw std::runtime_error("Compression_Alloc_Info::free got pointer not allocated by us"); + throw Exception("Compression_Alloc_Info::free got pointer not allocated by us"); zero_mem(ptr, i->second); std::free(ptr); @@ -64,7 +64,7 @@ Compressor_Transform* do_make_compressor(const std::string& type, const std::str Compressor_Transform* r = dynamic_cast<Compressor_Transform*>(t.get()); if(!r) - throw std::runtime_error("Bad cast of compression object " + t_name); + throw Exception("Bad cast of compression object " + t_name); t.release(); return r; @@ -228,7 +228,7 @@ void Stream_Decompression::finish(secure_vector<byte>& buf, size_t offset) process(buf, offset, m_stream->finish_flag()); if(m_stream.get()) - throw std::runtime_error(name() + " finished but not at stream end"); + throw Exception(name() + " finished but not at stream end"); } } diff --git a/src/lib/compression/compression.h b/src/lib/compression/compression.h index 2c74550d6..0a8079de8 100644 --- a/src/lib/compression/compression.h +++ b/src/lib/compression/compression.h @@ -28,7 +28,7 @@ class BOTAN_DLL Compressor_Transform : public Transform size_t output_length(size_t) const override final { - throw std::runtime_error(name() + " output length indeterminate"); + throw Exception(name() + " output length indeterminate"); } }; diff --git a/src/lib/compression/lzma/lzma.cpp b/src/lib/compression/lzma/lzma.cpp index 93a969d70..6e5217767 100644 --- a/src/lib/compression/lzma/lzma.cpp +++ b/src/lib/compression/lzma/lzma.cpp @@ -43,7 +43,7 @@ class LZMA_Stream : public Zlib_Style_Stream<lzma_stream, byte> if(rc == LZMA_MEM_ERROR) throw std::bad_alloc(); else if (rc != LZMA_OK && rc != LZMA_STREAM_END) - throw std::runtime_error("Lzma error"); + throw Exception("Lzma error"); return (rc == LZMA_STREAM_END); } @@ -63,7 +63,7 @@ class LZMA_Compression_Stream : public LZMA_Stream if(rc == LZMA_MEM_ERROR) throw std::bad_alloc(); else if(rc != LZMA_OK) - throw std::runtime_error("lzma compress initialization failed"); + throw Exception("lzma compress initialization failed"); } }; @@ -78,7 +78,7 @@ class LZMA_Decompression_Stream : public LZMA_Stream if(rc == LZMA_MEM_ERROR) throw std::bad_alloc(); else if(rc != LZMA_OK) - throw std::runtime_error("Bad setting in lzma_stream_decoder"); + 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 a6a724754..10422fff7 100644 --- a/src/lib/compression/zlib/zlib.cpp +++ b/src/lib/compression/zlib/zlib.cpp @@ -53,7 +53,7 @@ class Zlib_Compression_Stream : public Zlib_Stream int rc = deflateInit2(streamp(), level, Z_DEFLATED, wbits, 8, Z_DEFAULT_STRATEGY); if(rc != Z_OK) - throw std::runtime_error("zlib deflate initialization failed"); + throw Exception("zlib deflate initialization failed"); } ~Zlib_Compression_Stream() @@ -68,7 +68,7 @@ class Zlib_Compression_Stream : public Zlib_Stream if(rc == Z_MEM_ERROR) throw std::bad_alloc(); else if(rc != Z_OK && rc != Z_STREAM_END && rc != Z_BUF_ERROR) - throw std::runtime_error("zlib deflate error " + std::to_string(rc)); + throw Exception("zlib deflate error " + std::to_string(rc)); return (rc == Z_STREAM_END); } @@ -84,7 +84,7 @@ class Zlib_Decompression_Stream : public Zlib_Stream if(rc == Z_MEM_ERROR) throw std::bad_alloc(); else if(rc != Z_OK) - throw std::runtime_error("zlib inflate initialization failed"); + throw Exception("zlib inflate initialization failed"); } ~Zlib_Decompression_Stream() @@ -99,7 +99,7 @@ class Zlib_Decompression_Stream : public Zlib_Stream if(rc == Z_MEM_ERROR) throw std::bad_alloc(); else if(rc != Z_OK && rc != Z_STREAM_END && rc != Z_BUF_ERROR) - throw std::runtime_error("zlib inflate error " + std::to_string(rc)); + throw Exception("zlib inflate error " + std::to_string(rc)); return (rc == Z_STREAM_END); } @@ -130,7 +130,7 @@ class Gzip_Compression_Stream : public Zlib_Compression_Stream int rc = deflateSetHeader(streamp(), &m_header); if(rc != Z_OK) - throw std::runtime_error("setting gzip header failed"); + throw Exception("setting gzip header failed"); } private: |