Skip to content

Commit 0e78309

Browse files
committed
.NET: fix CA1031 warning - use specific exception types in CreateEqualityExpression method
1 parent 3c9fc7b commit 0e78309

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

dotnet/src/SemanticKernel.Core/Data/TextSearch/VectorStoreTextSearch.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -481,10 +481,19 @@ private async IAsyncEnumerable<string> GetResultsAsStringAsync(IAsyncEnumerable<
481481
// Create lambda: record => record.FieldName == value
482482
return Expression.Lambda<Func<TRecord, bool>>(equality, parameter);
483483
}
484-
catch (Exception)
484+
catch (ArgumentException)
485485
{
486-
// If any reflection or expression building fails, return null
487-
// This maintains backward compatibility rather than throwing exceptions
486+
// Invalid property name or expression parameter
487+
return null;
488+
}
489+
catch (InvalidOperationException)
490+
{
491+
// Expression building failed due to type incompatibility
492+
return null;
493+
}
494+
catch (TargetParameterCountException)
495+
{
496+
// Lambda expression parameter mismatch
488497
return null;
489498
}
490499
}

0 commit comments

Comments
 (0)