Skip to content
This repository was archived by the owner on Apr 8, 2025. It is now read-only.

Commit 770097d

Browse files
rahuldutta90vinjiang
authored andcommitted
Add the exception_ptr of the unhandled exception to retry_context
1 parent 6ea9817 commit 770097d

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

Microsoft.WindowsAzure.Storage/includes/was/core.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,8 +1203,8 @@ namespace azure { namespace storage {
12031203
/// <param name="last_request_result">The last request result.</param>
12041204
/// <param name="next_location">The next location to retry.</param>
12051205
/// <param name="current_location_mode">The current location mode.</param>
1206-
retry_context(int current_retry_count, request_result last_request_result, storage_location next_location, location_mode current_location_mode)
1207-
: m_current_retry_count(current_retry_count), m_last_request_result(std::move(last_request_result)), m_next_location(next_location), m_current_location_mode(current_location_mode)
1206+
retry_context(int current_retry_count, request_result last_request_result, storage_location next_location, location_mode current_location_mode, const std::exception_ptr& ex_ptr = nullptr)
1207+
: m_current_retry_count(current_retry_count), m_last_request_result(std::move(last_request_result)), m_next_location(next_location), m_current_location_mode(current_location_mode), m_unhandled_exception(ex_ptr)
12081208
{
12091209
}
12101210

@@ -1275,12 +1275,17 @@ namespace azure { namespace storage {
12751275
return m_current_location_mode;
12761276
}
12771277

1278+
const std::exception_ptr& unhandled_exception() const {
1279+
return m_unhandled_exception;
1280+
}
1281+
12781282
private:
12791283

12801284
int m_current_retry_count;
12811285
request_result m_last_request_result;
12821286
storage_location m_next_location;
12831287
location_mode m_current_location_mode;
1288+
std::exception_ptr m_unhandled_exception;
12841289
};
12851290

12861291
/// <summary>

Microsoft.WindowsAzure.Storage/src/executor.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ namespace azure { namespace storage { namespace core {
285285
{
286286
bool retryable_exception = true;
287287
instance->m_context._get_impl()->add_request_result(instance->m_request_result);
288+
std::exception_ptr ex_ptr = nullptr;
288289

289290
try
290291
{
@@ -297,6 +298,10 @@ namespace azure { namespace storage { namespace core {
297298
retryable_exception = e.retryable();
298299
throw;
299300
}
301+
catch (...) {
302+
ex_ptr = std::current_exception();
303+
throw;
304+
}
300305
}
301306
catch (const std::exception& e)
302307
{
@@ -336,7 +341,7 @@ namespace azure { namespace storage { namespace core {
336341
}
337342

338343
// An exception occurred and thus the request might be retried. Ask the retry policy.
339-
retry_context context(instance->m_retry_count++, instance->m_request_result, instance->get_next_location(), instance->m_current_location_mode);
344+
retry_context context(instance->m_retry_count++, instance->m_request_result, instance->get_next_location(), instance->m_current_location_mode, ex_ptr);
340345
retry_info retry(instance->m_retry_policy.evaluate(context, instance->m_context));
341346
if (!retry.should_retry())
342347
{

0 commit comments

Comments
 (0)