diff options
Diffstat (limited to 'src/lib/utils')
-rw-r--r-- | src/lib/utils/exceptn.cpp | 19 | ||||
-rw-r--r-- | src/lib/utils/exceptn.h | 8 |
2 files changed, 22 insertions, 5 deletions
diff --git a/src/lib/utils/exceptn.cpp b/src/lib/utils/exceptn.cpp index a72e45ba4..cc6eb9f85 100644 --- a/src/lib/utils/exceptn.cpp +++ b/src/lib/utils/exceptn.cpp @@ -11,18 +11,25 @@ namespace Botan { Exception::Exception(const std::string& msg) : m_msg(msg) {} +Exception::Exception(const std::string& msg, const std::exception& e) : + m_msg(msg + " failed with " + std::string(e.what())) + {} + Exception::Exception(const char* prefix, const std::string& msg) : m_msg(std::string(prefix) + " " + msg) {} Invalid_Argument::Invalid_Argument(const std::string& msg) : - Exception("Invalid argument", msg) + Exception(msg) {} Invalid_Argument::Invalid_Argument(const std::string& msg, const std::string& where) : - Exception("Invalid argument", msg + " in " + where) + Exception(msg + " in " + where) {} +Invalid_Argument::Invalid_Argument(const std::string& msg, const std::exception& e) : + Exception(msg, e) {} + Lookup_Error::Lookup_Error(const std::string& type, const std::string& algo, const std::string& provider) : @@ -76,11 +83,15 @@ Encoding_Error::Encoding_Error(const std::string& name) : {} Decoding_Error::Decoding_Error(const std::string& name) : - Invalid_Argument("Decoding error: " + name) + Invalid_Argument(name) + {} + +Decoding_Error::Decoding_Error(const std::string& msg, const std::exception& e) : + Invalid_Argument(msg, e) {} Decoding_Error::Decoding_Error(const std::string& name, const char* exception_message) : - Invalid_Argument("Decoding error: " + name + " failed with exception " + exception_message) {} + Invalid_Argument(name + " failed with exception " + exception_message) {} Integrity_Failure::Integrity_Failure(const std::string& msg) : Exception("Integrity failure: " + msg) diff --git a/src/lib/utils/exceptn.h b/src/lib/utils/exceptn.h index f2896aa83..efa52580c 100644 --- a/src/lib/utils/exceptn.h +++ b/src/lib/utils/exceptn.h @@ -23,6 +23,8 @@ class BOTAN_PUBLIC_API(2,0) Exception : public std::exception Exception(const char* prefix, const std::string& msg); explicit Exception(const std::string& msg); const char* what() const BOTAN_NOEXCEPT override { return m_msg.c_str(); } + protected: + Exception(const std::string& msg, const std::exception& e); private: std::string m_msg; }; @@ -36,7 +38,9 @@ class BOTAN_PUBLIC_API(2,0) Invalid_Argument : public Exception explicit Invalid_Argument(const std::string& msg); explicit Invalid_Argument(const std::string& msg, const std::string& where); -}; + + Invalid_Argument(const std::string& msg, const std::exception& e); + }; /** * Unsupported_Argument Exception @@ -178,6 +182,8 @@ class BOTAN_PUBLIC_API(2,0) Decoding_Error : public Invalid_Argument explicit Decoding_Error(const std::string& name); Decoding_Error(const std::string& name, const char* exception_message); + + Decoding_Error(const std::string& msg, const std::exception& e); }; /** |