diff --git a/io/cryptoexception.cpp b/io/cryptoexception.cpp index 91dedf0..f019ede 100644 --- a/io/cryptoexception.cpp +++ b/io/cryptoexception.cpp @@ -5,19 +5,4 @@ namespace Io { * \class CryptoException * \brief The exception that is thrown when an encryption/decryption error occurs. */ - -/*! - * \brief Constructs a crypto exception. - */ -CryptoException::CryptoException(const std::string &openSslErrorQueue) noexcept - : runtime_error(openSslErrorQueue) -{ -} - -/*! - * \brief Destroys the exception. - */ -CryptoException::~CryptoException() noexcept -{ -} } // namespace Io diff --git a/io/cryptoexception.h b/io/cryptoexception.h index 5054170..edb7abe 100644 --- a/io/cryptoexception.h +++ b/io/cryptoexception.h @@ -10,9 +10,26 @@ namespace Io { class PASSWORD_FILE_EXPORT CryptoException : public std::runtime_error { public: - CryptoException(const std::string &openSslErrorQueue) noexcept; - ~CryptoException() noexcept; + explicit CryptoException(const std::string &message) noexcept; + explicit CryptoException(const char *message) noexcept; }; + +/*! + * \brief Constructs a crypto exception. + */ +inline CryptoException::CryptoException(const std::string &message) noexcept + : runtime_error(message) +{ +} + +/*! + * \brief Constructs a crypto exception. + */ +inline CryptoException::CryptoException(const char *message) noexcept + : runtime_error(message) +{ +} + } // namespace Io #endif // PASSWORD_FILE_IO_CRYPTOFAILUREEXCEPTION_H diff --git a/io/parsingexception.cpp b/io/parsingexception.cpp index ff1af85..7116c6c 100644 --- a/io/parsingexception.cpp +++ b/io/parsingexception.cpp @@ -7,18 +7,4 @@ namespace Io { * \brief The exception that is thrown when a parsing error occurs. */ -/*! - * \brief Constructs a parsing exception. - */ -ParsingException::ParsingException(const std::string &message) noexcept - : runtime_error(message) -{ -} - -/*! - * \brief Destroys the exception. - */ -ParsingException::~ParsingException() noexcept -{ -} } // namespace Io diff --git a/io/parsingexception.h b/io/parsingexception.h index ca0dd7d..5011b6e 100644 --- a/io/parsingexception.h +++ b/io/parsingexception.h @@ -10,9 +10,26 @@ namespace Io { class PASSWORD_FILE_EXPORT ParsingException : public std::runtime_error { public: - ParsingException(const std::string &message = std::string()) noexcept; - ~ParsingException() noexcept; + explicit ParsingException(const std::string &message = std::string()) noexcept; + explicit ParsingException(const char *message) noexcept; }; + +/*! + * \brief Constructs a parsing exception. + */ +inline ParsingException::ParsingException(const std::string &message) noexcept + : runtime_error(message) +{ +} + +/*! + * \brief Constructs a parsing exception. + */ +inline ParsingException::ParsingException(const char *message) noexcept + : runtime_error(message) +{ +} + } // namespace Io #endif // PASSWORD_FILE_IO_PARSINGEXCEPTION_H diff --git a/io/passwordfile.cpp b/io/passwordfile.cpp index e05bc41..0387af9 100644 --- a/io/passwordfile.cpp +++ b/io/passwordfile.cpp @@ -293,7 +293,7 @@ void PasswordFile::load() msg += ERR_error_string(errorCode, nullptr); errorCode = ERR_get_error(); } - throw CryptoException(msg); + throw CryptoException(move(msg)); } if (ctx) { @@ -532,7 +532,7 @@ void PasswordFile::write(PasswordFileSaveFlags options) msg += ERR_error_string(errorCode, nullptr); errorCode = ERR_get_error(); } - throw CryptoException(msg); + throw CryptoException(move(msg)); } if (ctx) { diff --git a/util/opensslrandomdevice.cpp b/util/opensslrandomdevice.cpp index adf21c7..9512dc2 100644 --- a/util/opensslrandomdevice.cpp +++ b/util/opensslrandomdevice.cpp @@ -44,7 +44,7 @@ OpenSslRandomDevice::result_type OpenSslRandomDevice::operator()() const errorMsg += ERR_error_string(errorCode, nullptr); errorCode = ERR_get_error(); } - throw Io::CryptoException(errorMsg); + throw Io::CryptoException(move(errorMsg)); } /*!