-
Notifications
You must be signed in to change notification settings - Fork 515
AsyncCache: Adds support for stack trace optimization during exceptions for AsyncCache and AsyncCacheNonblocking #5069
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kirankumarkolli
merged 10 commits into
master
from
ananth/openai-exception-handling-asynccache
Mar 26, 2025
Merged
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
182c3a0
Async Cache and Async Cache Nonblocking exception handling changes
ananth7592 cd88058
Merge branch 'master' into ananth/openai-exception-handling-asynccache
kundadebdatta a66c65c
Code changes to merge master and hook exception stack optimization th…
kundadebdatta 6fdac6b
Add unit tests for ExceptionHandlingUtility
ananth7592 8ab0077
Modified the ExceptionHandlingUtility to TryClone model and letting t…
ananth7592 dd621d3
Merge branch 'master' into ananth/openai-exception-handling-asynccache
kirankumarkolli 8384882
Fixing the unit test
kirankumarkolli dfc7b78
Added support for all OperationCanceledException base types to Except…
ananth7592 bea502e
Updating unit tests
kirankumarkolli 644bc99
Including two more types
kirankumarkolli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// ------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// ------------------------------------------------------------ | ||
|
||
namespace Microsoft.Azure.Cosmos | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Microsoft.Azure.Documents; | ||
|
||
/// <summary> | ||
/// Utility for post-processing of exceptions. | ||
/// </summary> | ||
internal static class ExceptionHandlingUtility | ||
{ | ||
/// <summary> | ||
/// Tries to create a shallow copy of specific exception types (e.g., TaskCanceledException, TimeoutException, OperationCanceledException) | ||
/// to prevent excessive stack trace growth. Returns true if the exception was cloned, otherwise false. | ||
/// </summary> | ||
public static bool TryCloneException(Exception e, out Exception clonedException) | ||
{ | ||
clonedException = e switch | ||
{ | ||
ICloneable cloneableEx => (Exception)cloneableEx.Clone(), | ||
OperationCanceledException operationCanceledException => AddMessageData((Exception)Activator.CreateInstance(operationCanceledException.GetType(), operationCanceledException.Message, operationCanceledException), e), //Handles all OperationCanceledException types | ||
TimeoutException timeoutEx => AddMessageData(new TimeoutException(timeoutEx.Message, timeoutEx), e), | ||
_ => null | ||
}; | ||
|
||
return clonedException is not null; | ||
} | ||
|
||
private static Exception AddMessageData(Exception target, Exception source) | ||
{ | ||
if (source.Data.Contains("Message")) | ||
{ | ||
target.Data["Message"] = source.Data["Message"]; | ||
} | ||
|
||
return target; | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.