aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/ffi/ffi_util.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/ffi/ffi_util.h')
-rw-r--r--src/lib/ffi/ffi_util.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/lib/ffi/ffi_util.h b/src/lib/ffi/ffi_util.h
index 9ff1b0e2f..afd359dbb 100644
--- a/src/lib/ffi/ffi_util.h
+++ b/src/lib/ffi/ffi_util.h
@@ -43,7 +43,8 @@ struct botan_struct
struct NAME final : public Botan_FFI::botan_struct<TYPE, MAGIC> { explicit NAME(TYPE* x) : botan_struct(x) {} }
// Declared in ffi.cpp
-int ffi_error_exception_thrown(const char* func_name, const char* exn);
+int ffi_error_exception_thrown(const char* func_name, const char* exn,
+ int rc = BOTAN_FFI_ERROR_EXCEPTION_THROWN);
template<typename T, uint32_t M>
T& safe_get(botan_struct<T,M>* p)
@@ -69,7 +70,15 @@ int ffi_guard_thunk(const char* func_name, Thunk thunk)
}
catch(std::bad_alloc&)
{
- return ffi_error_exception_thrown(func_name, "bad_alloc");
+ return ffi_error_exception_thrown(func_name, "bad_alloc", BOTAN_FFI_ERROR_OUT_OF_MEMORY);
+ }
+ catch(Botan::Key_Not_Set& e)
+ {
+ return ffi_error_exception_thrown(func_name, e.what(), BOTAN_FFI_ERROR_KEY_NOT_SET);
+ }
+ catch(Botan::Invalid_Argument& e)
+ {
+ return ffi_error_exception_thrown(func_name, e.what(), BOTAN_FFI_ERROR_BAD_PARAMETER);
}
catch(std::exception& e)
{