Skip to content

Commit

Permalink
fix: search via Elastic should return 500 when Elastic fails
Browse files Browse the repository at this point in the history
  • Loading branch information
rikdepeuter committed Dec 11, 2024
1 parent 6fe3b31 commit 7ae396a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AddressRegistry.Infrastructure.Elastic.Exceptions;
using Be.Vlaanderen.Basisregisters.GrAr.Legacy.Adres;
using Convertors;
using global::Elastic.Clients.Elasticsearch;
Expand Down Expand Up @@ -134,8 +135,7 @@ public async Task<AddressSearchResult> ListAddresses(

if (!searchResponse.IsValidResponse)
{
_logger.LogWarning("Failed to search for addresses: {Error}", searchResponse.ElasticsearchServerError);
return new AddressSearchResult(Enumerable.Empty<AddressSearchDocument>().ToList(), 0);
throw new ElasticsearchClientException("Failed to search for addresses", searchResponse.ElasticsearchServerError, searchResponse.DebugInformation);
}

return new AddressSearchResult(searchResponse.Documents, searchResponse.Total);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Text.Json;
using System.Threading.Tasks;
using AddressRegistry.Infrastructure.Elastic;
using AddressRegistry.Infrastructure.Elastic.Exceptions;
using global::Elastic.Clients.Elasticsearch;
using global::Elastic.Clients.Elasticsearch.QueryDsl;
using Microsoft.Extensions.Logging;
Expand Down Expand Up @@ -89,8 +90,7 @@ public async Task<AddressSearchResult> SearchAddresses(

if (!searchResponse.IsValidResponse)
{
_logger.LogWarning("Failed to search for addresses: {Error}", searchResponse.ElasticsearchServerError);
return AddressSearchResult.Empty;
throw new ElasticsearchClientException("Failed to search for addresses", searchResponse.ElasticsearchServerError, searchResponse.DebugInformation);
}

var language = DetermineLanguage(searchResponse);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Text.Json;
using System.Threading.Tasks;
using AddressRegistry.Infrastructure.Elastic;
using AddressRegistry.Infrastructure.Elastic.Exceptions;
using Consumer.Read.StreetName.Projections;
using Consumer.Read.StreetName.Projections.Elastic;
using global::Elastic.Clients.Elasticsearch;
Expand Down Expand Up @@ -97,8 +98,7 @@ public async Task<StreetNameSearchResult> SearchStreetNames(

if (!searchResponse.IsValidResponse)
{
_logger.LogWarning("Failed to search for streetnames: {Error}", searchResponse.ElasticsearchServerError);
return StreetNameSearchResult.Empty;
throw new ElasticsearchClientException("Failed to search for streetnames", searchResponse.ElasticsearchServerError, searchResponse.DebugInformation);
}

var language = DetermineLanguage(searchResponse);
Expand Down

0 comments on commit 7ae396a

Please sign in to comment.