Skip to content

Commit 55d343b

Browse files
authored
Rename IndexNotFound to IndexNotFoundException (#488)
Renames `IndexNotFound` to `IndexNotFoundException` across the codebase to align with naming conventions. Related to #487
1 parent f1c73c6 commit 55d343b

File tree

9 files changed

+28
-28
lines changed

9 files changed

+28
-28
lines changed

extensions/AzureAISearch/AzureAISearch/AzureAISearchMemory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ await client.IndexDocumentsAsync(
150150
}
151151
catch (RequestFailedException e) when (IsIndexNotFoundException(e))
152152
{
153-
throw new IndexNotFound(e.Message, e);
153+
throw new IndexNotFoundException(e.Message, e);
154154
}
155155

156156
foreach (var record in records)

extensions/Postgres/Postgres/Internals/PostgresDbClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ DO UPDATE SET
365365
}
366366
catch (Npgsql.PostgresException e) when (IsTableNotFoundException(e))
367367
{
368-
throw new IndexNotFound(e.Message, e);
368+
throw new IndexNotFoundException(e.Message, e);
369369
}
370370
catch (Exception e)
371371
{

extensions/Qdrant/Qdrant/Internals/QdrantClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ private void ValidateResponse(HttpResponseMessage response, string content, stri
431431
if (response.StatusCode == HttpStatusCode.NotFound && responseContent.Contains("Not found: Collection", StringComparison.OrdinalIgnoreCase))
432432
{
433433
this._log.LogWarning("Qdrant collection not found: {0}, {1}", response.StatusCode, responseContent);
434-
throw new IndexNotFound(responseContent);
434+
throw new IndexNotFoundException(responseContent);
435435
}
436436

437437
if (!responseContent.Contains("already exists", StringComparison.OrdinalIgnoreCase))

extensions/Qdrant/Qdrant/QdrantMemory.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public Task DeleteIndexAsync(
7878
index = NormalizeIndexName(index);
7979
return this._qdrantClient.DeleteCollectionAsync(index, cancellationToken);
8080
}
81-
catch (IndexNotFound)
81+
catch (IndexNotFoundException)
8282
{
8383
this._log.LogInformation("Index not found, nothing to delete");
8484
}
@@ -163,7 +163,7 @@ public async Task<string> UpsertAsync(
163163
withVectors: withEmbeddings,
164164
cancellationToken: cancellationToken).ConfigureAwait(false);
165165
}
166-
catch (IndexNotFound e)
166+
catch (IndexNotFoundException e)
167167
{
168168
this._log.LogWarning(e, "Index not found");
169169
// Nothing to return
@@ -207,7 +207,7 @@ public async IAsyncEnumerable<MemoryRecord> GetListAsync(
207207
withVectors: withEmbeddings,
208208
cancellationToken: cancellationToken).ConfigureAwait(false);
209209
}
210-
catch (IndexNotFound e)
210+
catch (IndexNotFoundException e)
211211
{
212212
this._log.LogWarning(e, "Index not found");
213213
// Nothing to return
@@ -242,7 +242,7 @@ public async Task DeleteAsync(
242242
this._log.LogTrace("Point ID {0} found, deleting...", existingPoint.Id);
243243
await this._qdrantClient.DeleteVectorsAsync(index, new List<Guid> { existingPoint.Id }, cancellationToken).ConfigureAwait(false);
244244
}
245-
catch (IndexNotFound e)
245+
catch (IndexNotFoundException e)
246246
{
247247
this._log.LogInformation(e, "Index not found, nothing to delete");
248248
}

service/Abstractions/MemoryStorage/IMemoryDb.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Task DeleteIndexAsync(
4545
/// <param name="record">Vector + payload to save</param>
4646
/// <param name="cancellationToken">Task cancellation token</param>
4747
/// <returns>Record ID</returns>
48-
/// <exception cref="IndexNotFound">Error returned if the index where to write doesn't exist</exception>
48+
/// <exception cref="IndexNotFoundException">Error returned if the index where to write doesn't exist</exception>
4949
Task<string> UpsertAsync(
5050
string index,
5151
MemoryRecord record,

service/Abstractions/MemoryStorage/IMemoryDbBatchUpsert.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public interface IMemoryDbBatchUpsert
1919
/// <param name="records">Vectors + payload to save</param>
2020
/// <param name="cancellationToken">Task cancellation token</param>
2121
/// <returns>Record IDs</returns>
22-
/// <exception cref="IndexNotFound">Error returned if the index where to write doesn't exist</exception>
22+
/// <exception cref="IndexNotFoundException">Error returned if the index where to write doesn't exist</exception>
2323
IAsyncEnumerable<string> BatchUpsertAsync(
2424
string index,
2525
IEnumerable<MemoryRecord> records,

service/Abstractions/MemoryStorage/IndexNotFound.cs

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
3+
using System;
4+
5+
namespace Microsoft.KernelMemory.MemoryStorage;
6+
7+
public class IndexNotFoundException : KernelMemoryException
8+
{
9+
/// <inheritdoc />
10+
public IndexNotFoundException() { }
11+
12+
/// <inheritdoc />
13+
public IndexNotFoundException(string message) : base(message) { }
14+
15+
/// <inheritdoc />
16+
public IndexNotFoundException(string message, Exception? innerException) : base(message, innerException) { }
17+
}

service/Core/Handlers/SaveRecordsHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ private async Task SaveRecordAsync(DataPipeline pipeline, IMemoryDb db, MemoryRe
265265
this._log.LogTrace("Saving record {0} in index '{1}'", record.Id, pipeline.Index);
266266
await db.UpsertAsync(pipeline.Index, record, cancellationToken).ConfigureAwait(false);
267267
}
268-
catch (IndexNotFound e)
268+
catch (IndexNotFoundException e)
269269
{
270270
this._log.LogWarning(e, "Index {0} not found, attempting to create it", pipeline.Index);
271271
await this.CreateIndexOnceAsync(db, createdIndexes, pipeline.Index, record.Vector.Length, cancellationToken, true).ConfigureAwait(false);
@@ -284,7 +284,7 @@ private async Task SaveRecordsBatchAsync(DataPipeline pipeline, IMemoryDb db, Li
284284
this._log.LogTrace("Saving batch of {0} records in index '{1}'", records.Count, pipeline.Index);
285285
await dbBatch.BatchUpsertAsync(pipeline.Index, records, cancellationToken).ToListAsync(cancellationToken).ConfigureAwait(false);
286286
}
287-
catch (IndexNotFound e)
287+
catch (IndexNotFoundException e)
288288
{
289289
this._log.LogWarning(e, "Index {0} not found, attempting to create it", pipeline.Index);
290290
await this.CreateIndexOnceAsync(db, createdIndexes, pipeline.Index, records[0].Vector.Length, cancellationToken, true).ConfigureAwait(false);

0 commit comments

Comments
 (0)