From 2aa7fcf031be23073c378840dfba37378c00bf9f Mon Sep 17 00:00:00 2001 From: Andy Staples Date: Fri, 29 Aug 2025 15:24:31 -0600 Subject: [PATCH] Loosen exception matching logic in IsCausedBy --- src/DurableTask.Core/FailureDetails.cs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/DurableTask.Core/FailureDetails.cs b/src/DurableTask.Core/FailureDetails.cs index 5dfd02ab9..d6e1c7c30 100644 --- a/src/DurableTask.Core/FailureDetails.cs +++ b/src/DurableTask.Core/FailureDetails.cs @@ -149,14 +149,10 @@ public bool IsCausedBy() where T : Exception .Select(a => a.GetType(this.ErrorType, throwOnError: false)) .Where(t => t is not null) .ToList(); - if (matchingExceptionTypes.Count == 1) - { - exceptionType = matchingExceptionTypes[0]; - } - else if (matchingExceptionTypes.Count > 1) - { - throw new AmbiguousMatchException($"Multiple exception types with the name '{this.ErrorType}' were found."); - } + + // Previously, this logic would only return true if matchingExceptionTypes found only one assembly with a type matching ErrorType. + // Now, it will return true if any matching assembly has a type that is assignable to T. + return matchingExceptionTypes.Any(matchType => typeof(T).IsAssignableFrom(matchType)); } return exceptionType != null && typeof(T).IsAssignableFrom(exceptionType);