Skip to content

Commit

Permalink
Merge pull request #994 from IgorAlymov/SITKO-CORE-T-19
Browse files Browse the repository at this point in the history
fix: fixed logs for OpenSearch
  • Loading branch information
pogromistik authored Jul 26, 2024
2 parents 9bcfcf7 + 2dd866b commit 7c7e174
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions src/Sitko.Core.Search.OpenSearch/OpenSearchSearcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ public async Task<bool> DeleteAsync(string indexName, IEnumerable<TSearchModel>
foreach (var item in result.ItemsWithErrors)
{
logger.LogError("Error while deleting document {Id} from {IndexName}: {ErrorText}", item.Id,
indexName,
item.Error);
indexName, item.Error);
}
}

Expand Down Expand Up @@ -148,8 +147,19 @@ public async Task InitAsync(string indexName, CancellationToken cancellationToke
await GetClient().Indices.OpenAsync(indexName, ct: cancellationToken);
if (!result.IsValid)
{
logger.LogError(result.OriginalException?.Message);
throw result.OriginalException;
if (result.ServerError != null)
{
logger.LogError("Error while init {IndexName} index: {ErrorText}", indexName,
result.ServerError);
throw new InvalidOperationException("Error while init " + indexName + " index: " +
result.ServerError);
}

if (result.OriginalException != null)
{
logger.LogError(result.OriginalException.Message);
throw result.OriginalException;
}
}
}
else
Expand All @@ -158,8 +168,19 @@ public async Task InitAsync(string indexName, CancellationToken cancellationToke
var result = await GetClient().Indices.CreateAsync(indexName, CreateIndexDescriptor, ct: cancellationToken);
if (!result.IsValid)
{
logger.LogError(result.OriginalException?.Message);
throw result.OriginalException;
if (result.ServerError != null)
{
logger.LogError("Error while create {IndexName} index: {ErrorText}", indexName,
result.ServerError);
throw new InvalidOperationException("Error while init " + indexName + " index: " +
result.ServerError);
}

if (result.OriginalException != null)
{
logger.LogError(result.OriginalException.Message);
throw result.OriginalException;
}
}
}
}
Expand Down

0 comments on commit 7c7e174

Please sign in to comment.