diff --git a/sdk/core/azure-core/CHANGELOG.md b/sdk/core/azure-core/CHANGELOG.md index a1a162eec..ec0717fde 100644 --- a/sdk/core/azure-core/CHANGELOG.md +++ b/sdk/core/azure-core/CHANGELOG.md @@ -9,6 +9,7 @@ ### New Features - Added `strings.hpp` with `Azure::Core::Strings::LocaleInvariantCaseInsensitiveEqual` and `Azure::Core::Strings::ToLower`. +- Added `OperationCanceledException`. ### Other changes and Improvements @@ -32,6 +33,7 @@ - Throw Azure::Http::TransportException if creating new connection fails. - Response objects store Nullable\. +- Calling `Cancel()` from context now throws `OperationCanceledException`. ### 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 d3774d834..34defee6e 100644 --- a/sdk/core/azure-core/inc/azure/core/context.hpp +++ b/sdk/core/azure-core/inc/azure/core/context.hpp @@ -26,9 +26,9 @@ namespace Azure { namespace Core { virtual ~ValueBase() {} }; - struct RequestCanceledException : public std::runtime_error + struct OperationCanceledException : public std::runtime_error { - explicit RequestCanceledException(std::string const& msg) : std::runtime_error(msg) {} + explicit OperationCanceledException(std::string const& message) : std::runtime_error(message) {} }; /** @@ -389,7 +389,7 @@ namespace Azure { namespace Core { { if (CancelWhen() < std::chrono::system_clock::now()) { - throw RequestCanceledException("Request was canceled by context."); + throw OperationCanceledException("Request was canceled by context."); } } }; diff --git a/sdk/core/azure-core/test/ut/transport_adapter.cpp b/sdk/core/azure-core/test/ut/transport_adapter.cpp index 47c141435..8d218e5a5 100644 --- a/sdk/core/azure-core/test/ut/transport_adapter.cpp +++ b/sdk/core/azure-core/test/ut/transport_adapter.cpp @@ -444,7 +444,7 @@ namespace Azure { namespace Core { namespace Test { = Azure::Core::Http::Request(Azure::Core::Http::HttpMethod::Put, host, &stream); // Request will be canceled from main thread throwing the exception - EXPECT_THROW(pipeline.Send(cancelThis, request), Azure::Core::RequestCanceledException); + EXPECT_THROW(pipeline.Send(cancelThis, request), Azure::Core::OperationCanceledException); }; // Start request @@ -467,7 +467,7 @@ namespace Azure { namespace Core { namespace Test { auto request = Azure::Core::Http::Request(Azure::Core::Http::HttpMethod::Get, host); // Request will be canceled from main thread throwing the exception - EXPECT_THROW(pipeline.Send(cancelThis, request), Azure::Core::RequestCanceledException); + EXPECT_THROW(pipeline.Send(cancelThis, request), Azure::Core::OperationCanceledException); }; // Start request