Skip to content

Commit 0034a02

Browse files
Potential fix for pull request finding 'Generic catch clause'
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
1 parent f6f118b commit 0034a02

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/Elastic.Markdown/Exporters/Elasticsearch/Enrichment/ElasticsearchEnrichmentCache.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,21 @@ private async Task PersistToElasticsearchAsync(string key, EnrichmentData data,
8282
if (!response.ApiCallDetails.HasSuccessfulStatusCode)
8383
_logger.LogWarning("Failed to persist cache entry: {StatusCode}", response.ApiCallDetails.HttpStatusCode);
8484
}
85+
catch (OperationCanceledException)
86+
{
87+
// Respect cancellation requests and allow callers to observe them.
88+
throw;
89+
}
90+
catch (TransportException tex)
91+
{
92+
// Transport-related failures are treated as best-effort cache persistence issues.
93+
_logger.LogWarning(tex, "Failed to persist cache entry for key {Key}", key);
94+
}
8595
catch (Exception ex)
8696
{
87-
_logger.LogWarning(ex, "Failed to persist cache entry for key {Key}", key);
97+
// Unexpected exceptions are logged and rethrown to avoid silently swallowing serious issues.
98+
_logger.LogError(ex, "Unexpected error while persisting cache entry for key {Key}", key);
99+
throw;
88100
}
89101
}
90102

0 commit comments

Comments
 (0)