From 913cb543c82cd36779aae449423eb668eebe32d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com> Date: Sat, 30 Nov 2019 19:42:02 -0500 Subject: [PATCH] crypto: improve exception types --- include/opendht/crypto.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/include/opendht/crypto.h b/include/opendht/crypto.h index 72eda3d5..17ef2b2d 100644 --- a/include/opendht/crypto.h +++ b/include/opendht/crypto.h @@ -43,16 +43,22 @@ namespace dht { namespace crypto { class OPENDHT_PUBLIC CryptoException : public std::runtime_error { - public: - CryptoException(const std::string& str) : std::runtime_error(str) {}; +public: + explicit CryptoException(const std::string& str) : std::runtime_error(str) {}; + explicit CryptoException(const char* str) : std::runtime_error(str) {}; + CryptoException(const CryptoException& e) noexcept = default; + CryptoException& operator=(const CryptoException&) noexcept = default; }; /** * Exception thrown when a decryption error happened. */ class OPENDHT_PUBLIC DecryptError : public CryptoException { - public: - DecryptError(const std::string& str = "") : CryptoException(str) {}; +public: + explicit DecryptError(const std::string& str) : CryptoException(str) {}; + explicit DecryptError(const char* str) : CryptoException(str) {}; + DecryptError(const DecryptError& e) noexcept = default; + DecryptError& operator=(const DecryptError&) noexcept = default; }; struct PrivateKey; -- GitLab