From b9aa2c792499f33589f1f04b9c664cdbdfeb0742 Mon Sep 17 00:00:00 2001 From: Daniel <d.hornung@indiscale.com> Date: Fri, 30 Jul 2021 14:04:56 +0200 Subject: [PATCH] MAINT: Renamed GenericException -> Exception. --- include/caosdb/exceptions.h | 24 ++++++++++++------------ include/caosdb/transaction_status.h | 4 ++-- src/caosdb/configuration.cpp | 4 ++-- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/include/caosdb/exceptions.h b/include/caosdb/exceptions.h index cd60323..4653ed2 100644 --- a/include/caosdb/exceptions.h +++ b/include/caosdb/exceptions.h @@ -32,9 +32,9 @@ using std::runtime_error; /** * @brief Generic exception class of the caosdb client library. */ -class GenericException : public runtime_error { +class Exception : public runtime_error { public: - explicit GenericException(StatusCode code, const std::string &what_arg) + explicit Exception(StatusCode code, const std::string &what_arg) : runtime_error(what_arg), code(code) {} [[nodiscard]] inline auto GetCode() const -> StatusCode { return this->code; } @@ -45,47 +45,47 @@ private: /** * @brief Exception for authentication errors. */ -class AuthenticationError : public GenericException { +class AuthenticationError : public Exception { public: explicit AuthenticationError(const std::string &what_arg) - : GenericException(StatusCode::AUTHENTICATION_ERROR, what_arg) {} + : Exception(StatusCode::AUTHENTICATION_ERROR, what_arg) {} }; /** * @brief The connection to the CaosDB server is down. */ -class ConnectionError : public GenericException { +class ConnectionError : public Exception { public: explicit ConnectionError(const std::string &what_arg) - : GenericException(StatusCode::CONNECTION_ERROR, what_arg) {} + : Exception(StatusCode::CONNECTION_ERROR, what_arg) {} }; /** * @brief The transaction terminated unsuccessfully. */ -class TransactionError : public GenericException { +class TransactionError : public Exception { public: explicit TransactionError(const std::string &what_arg) - : GenericException(StatusCode::GENERIC_TRANSACTION_ERROR, what_arg) {} + : Exception(StatusCode::GENERIC_TRANSACTION_ERROR, what_arg) {} }; /** * @brief Exception for errors of the ConfigurationManager or other components * of the configuration. */ -class ConfigurationError : public GenericException { +class ConfigurationError : public Exception { public: explicit ConfigurationError(const std::string &what_arg) - : GenericException(StatusCode::CONFIGURATION_ERROR, what_arg) {} + : Exception(StatusCode::CONFIGURATION_ERROR, what_arg) {} }; /** * @brief The connection isn't known to the ConnectionManager under this name. */ -class UnknownConnectionError : public GenericException { +class UnknownConnectionError : public Exception { public: explicit UnknownConnectionError(const std::string &what_arg) - : GenericException(StatusCode::UNKNOWN_CONNECTION_ERROR, what_arg) {} + : Exception(StatusCode::UNKNOWN_CONNECTION_ERROR, what_arg) {} }; } // namespace caosdb::exceptions diff --git a/include/caosdb/transaction_status.h b/include/caosdb/transaction_status.h index 8645ace..ff5029c 100644 --- a/include/caosdb/transaction_status.h +++ b/include/caosdb/transaction_status.h @@ -35,7 +35,7 @@ namespace caosdb::transaction { using caosdb::StatusCode; using caosdb::exceptions::AuthenticationError; using caosdb::exceptions::ConnectionError; -using caosdb::exceptions::GenericException; +using caosdb::exceptions::Exception; using caosdb::exceptions::TransactionError; /** @@ -113,7 +113,7 @@ public: case StatusCode::GENERIC_TRANSACTION_ERROR: throw TransactionError(this->description); default: - throw GenericException(StatusCode::GENERIC_ERROR, this->description); + throw Exception(StatusCode::GENERIC_ERROR, this->description); } } diff --git a/src/caosdb/configuration.cpp b/src/caosdb/configuration.cpp index ed3385a..4a1f2a6 100644 --- a/src/caosdb/configuration.cpp +++ b/src/caosdb/configuration.cpp @@ -357,7 +357,7 @@ auto ConfigurationManager::mReset() noexcept -> int { mClear(); InitializeDefaults(); return StatusCode::SUCCESS; - } catch (const caosdb::exceptions::GenericException &exc) { + } catch (const caosdb::exceptions::Exception &exc) { return exc.GetCode(); } catch (const std::exception &exc) { CAOSDB_LOG_ERROR(logger_name) @@ -372,7 +372,7 @@ auto ConfigurationManager::mClear() noexcept -> int { json_configuration = value(nullptr); ConnectionManager::Reset(); return StatusCode::SUCCESS; - } catch (const caosdb::exceptions::GenericException &exc) { + } catch (const caosdb::exceptions::Exception &exc) { return exc.GetCode(); } catch (const std::exception &exc) { CAOSDB_LOG_ERROR(logger_name) -- GitLab