From 5d0e7734c4ef1f9113c760cd70f42ea5cc3e0856 Mon Sep 17 00:00:00 2001 From: Victor Vazquez Date: Wed, 21 Oct 2020 19:53:46 -0700 Subject: [PATCH] update exceptions to be a class instead of an struct (#833) Fixes: https://github.com/Azure/azure-sdk-for-cpp/issues/828 --- sdk/core/azure-core/CHANGELOG.md | 1 + sdk/core/azure-core/inc/azure/core/context.hpp | 13 +++++++++++-- sdk/core/azure-core/inc/azure/core/exception.hpp | 4 ++-- sdk/core/azure-core/inc/azure/core/http/http.hpp | 8 ++++---- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/sdk/core/azure-core/CHANGELOG.md b/sdk/core/azure-core/CHANGELOG.md index ec0717fde..b86c8f474 100644 --- a/sdk/core/azure-core/CHANGELOG.md +++ b/sdk/core/azure-core/CHANGELOG.md @@ -14,6 +14,7 @@ ### Other changes and Improvements - Add high-level and simplified core.hpp file for simpler include experience for customers. +- Update SDK-defined exception types to be classes instead of structs. ### Bug Fixes diff --git a/sdk/core/azure-core/inc/azure/core/context.hpp b/sdk/core/azure-core/inc/azure/core/context.hpp index 34defee6e..164dec8e7 100644 --- a/sdk/core/azure-core/inc/azure/core/context.hpp +++ b/sdk/core/azure-core/inc/azure/core/context.hpp @@ -26,8 +26,17 @@ namespace Azure { namespace Core { virtual ~ValueBase() {} }; - struct OperationCanceledException : public std::runtime_error - { + /** + * @brief An exception that gets thrown when some operation is canceled. + * + */ + class OperationCanceledException : public std::runtime_error { + public: + /** + * @brief Construct with message string as description. + * + * @param message The description for the exception. + */ explicit OperationCanceledException(std::string const& message) : std::runtime_error(message) {} }; diff --git a/sdk/core/azure-core/inc/azure/core/exception.hpp b/sdk/core/azure-core/inc/azure/core/exception.hpp index ee05552f7..2a1ef9fa1 100644 --- a/sdk/core/azure-core/inc/azure/core/exception.hpp +++ b/sdk/core/azure-core/inc/azure/core/exception.hpp @@ -15,8 +15,8 @@ namespace Azure { namespace Core { * @brief An error while trying to send a request to Azure service. * */ - struct RequestFailedException : public std::runtime_error - { + class RequestFailedException : public std::runtime_error { + public: /** * @brief Construct a new Request Failed Exception object. * diff --git a/sdk/core/azure-core/inc/azure/core/http/http.hpp b/sdk/core/azure-core/inc/azure/core/http/http.hpp index 2a60ac453..10c74d803 100644 --- a/sdk/core/azure-core/inc/azure/core/http/http.hpp +++ b/sdk/core/azure-core/inc/azure/core/http/http.hpp @@ -52,8 +52,8 @@ namespace Azure { namespace Core { namespace Http { /** * @brief HTTP transport layer error. */ - struct TransportException : public Azure::Core::RequestFailedException - { + class TransportException : public Azure::Core::RequestFailedException { + public: /** * @brief An error while sending the HTTP request with the transport adapter. * @@ -72,8 +72,8 @@ namespace Azure { namespace Core { namespace Http { * @brief An invalid header key name in @Request or @RawResponse. * */ - struct InvalidHeaderException : public Azure::Core::RequestFailedException - { + class InvalidHeaderException : public Azure::Core::RequestFailedException { + public: /** * @brief An invalid header key name detected in the HTTP request or response. *