diff options
Diffstat (limited to 'src/lib/utils/exceptn.h')
-rw-r--r-- | src/lib/utils/exceptn.h | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/src/lib/utils/exceptn.h b/src/lib/utils/exceptn.h index eef1b4d43..c9b45f916 100644 --- a/src/lib/utils/exceptn.h +++ b/src/lib/utils/exceptn.h @@ -16,8 +16,28 @@ namespace Botan { -typedef std::runtime_error Exception; -typedef std::invalid_argument Invalid_Argument; +/** +* Base class for all exceptions thrown by the library +*/ +class BOTAN_DLL Exception : public std::exception + { + public: + Exception(const std::string& what) : m_what(what) {} + Exception(const char* prefix, const std::string& what) : m_what(std::string(prefix) + " " + what) {} + const char* what() const override { return m_what.c_str(); } + private: + std::string m_what; + }; + +/** +* An invalid argument which caused +*/ +class BOTAN_DLL Invalid_Argument : public Exception + { + public: + Invalid_Argument(const std::string& what) : + Exception("Invalid argument", what) {} + }; /** * Unsupported_Argument Exception @@ -196,15 +216,6 @@ struct BOTAN_DLL Self_Test_Failure : public Internal_Error {} }; -/** -* Memory Allocation Exception -*/ -struct BOTAN_DLL Memory_Exhaustion : public std::bad_alloc - { - const char* what() const BOTAN_NOEXCEPT override - { return "Ran out of memory, allocation failed"; } - }; - } #endif |