aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/ffi/ffi.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2015-12-11 09:42:06 -0500
committerJack Lloyd <[email protected]>2015-12-11 09:42:06 -0500
commit6b9a3a534071ef84c121c406559f8fc7ad546104 (patch)
treec11480ad1f07e443ba4e992fefcd618b532c2e93 /src/lib/ffi/ffi.cpp
parent79a51627ee11f4d7f55d589751b30463d1f02a76 (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/ffi/ffi.cpp')
-rw-r--r--src/lib/ffi/ffi.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/lib/ffi/ffi.cpp b/src/lib/ffi/ffi.cpp
index eaf24eca6..dac4cafad 100644
--- a/src/lib/ffi/ffi.cpp
+++ b/src/lib/ffi/ffi.cpp
@@ -59,7 +59,7 @@
namespace {
#define BOTAN_ASSERT_ARG_NON_NULL(p) \
- do { if(!p) throw std::invalid_argument("Argument " #p " is null"); } while(0)
+ do { if(!p) throw Invalid_Argument("Argument " #p " is null"); } while(0)
template<typename T, uint32_t MAGIC>
struct botan_struct
@@ -71,7 +71,7 @@ struct botan_struct
T* get() const
{
if(m_magic != MAGIC)
- throw std::runtime_error("Bad magic " + std::to_string(m_magic) +
+ throw Exception("Bad magic " + std::to_string(m_magic) +
" in ffi object expected " + std::to_string(MAGIC));
return m_obj.get();
}
@@ -95,10 +95,10 @@ template<typename T, uint32_t M>
T& safe_get(botan_struct<T,M>* p)
{
if(!p)
- throw std::runtime_error("Null pointer argument");
+ throw Exception("Null pointer argument");
if(T* t = p->get())
return *t;
- throw std::runtime_error("Invalid object pointer");
+ throw Exception("Invalid object pointer");
}
template<typename T, uint32_t M, typename F>
@@ -107,7 +107,7 @@ int apply_fn(botan_struct<T, M>* o, const char* func_name, F func)
try
{
if(!o)
- throw std::runtime_error("Null object to " + std::string(func_name));
+ throw Exception("Null object to " + std::string(func_name));
if(T* t = o->get())
return func(*t);
}
@@ -677,7 +677,7 @@ int botan_bcrypt_generate(uint8_t* out, size_t* out_len,
return BOTAN_FFI_ERROR_BAD_FLAG;
if(wf < 2 || wf > 30)
- throw std::runtime_error("Bad bcrypt work factor " + std::to_string(wf));
+ throw Exception("Bad bcrypt work factor " + std::to_string(wf));
#if defined(BOTAN_HAS_BCRYPT)
Botan::RandomNumberGenerator& rng = safe_get(rng_obj);