fix: Improve error handling in OllamaClient by logging errors and throwing exceptions

This commit is contained in:
extio-de
2026-05-10 19:25:26 +02:00
parent f97d758afd
commit 5b06de15b4

View File

@@ -452,16 +452,16 @@ public class OllamaClient implements Client {
.toList(); .toList();
} }
catch (final RestClientResponseException e) { catch (final RestClientResponseException e) {
LOGGER.warn("Failed to load Ollama model names: {} {}", e.getStatusCode(), e.getStatusText()); LOGGER.error("Failed to load Ollama model names: {} {}", e.getStatusCode(), e.getStatusText());
return List.of(); throw new IllegalStateException("Failed to load Ollama model names: " + e.getStatusCode() + " " + e.getStatusText(), e);
} }
catch (final RestClientException e) { catch (final RestClientException e) {
LOGGER.warn("Failed to load Ollama model names: {}", e.getMessage()); LOGGER.error("Failed to load Ollama model names: {}", e.getMessage());
return List.of(); throw new IllegalStateException("Failed to load Ollama model names: " + e.getMessage(), e);
} }
catch (final RuntimeException e) { catch (final RuntimeException e) {
LOGGER.warn("Failed to load Ollama model names", e); LOGGER.error("Failed to load Ollama model names", e);
return List.of(); throw new IllegalStateException("Failed to load Ollama model names: " + e.getMessage(), e);
} }
} }