From 5a62cb26ac1bc436bd024b5ae0e10aa07acdd10d Mon Sep 17 00:00:00 2001 From: Andrew Berezovskyi Date: Tue, 31 Dec 2024 23:07:26 +0100 Subject: [PATCH] refactor: better fault handling --- backend/src/main/java/sparqles/utils/FaultDiagnostic.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/backend/src/main/java/sparqles/utils/FaultDiagnostic.java b/backend/src/main/java/sparqles/utils/FaultDiagnostic.java index 5fa7eced..d4cda487 100644 --- a/backend/src/main/java/sparqles/utils/FaultDiagnostic.java +++ b/backend/src/main/java/sparqles/utils/FaultDiagnostic.java @@ -19,8 +19,7 @@ public static FaultKind faultKindForJenaQuery(Exception e) { if (e == null) { throw new NullPointerException("Exception shall not be null"); } - if (e instanceof QueryExceptionHTTP) { - var qe = (QueryExceptionHTTP) e; + if (e instanceof QueryExceptionHTTP qe) { if (e.getCause() instanceof UnknownHostException) { return FaultKind.DOWN_HOST_NOT_FOUND; } @@ -31,7 +30,7 @@ public static FaultKind faultKindForJenaQuery(Exception e) { } if (e.getCause() instanceof SSLHandshakeException) { return FaultKind.DOWN_TLS_CONFIGURATION_ERROR; - } else if (e.getCause() instanceof HttpException) { + } else if (e.getCause() instanceof HttpException || qe.getStatusCode() >= 400) { return faultKindForApacheHttpException(qe.getStatusCode()); } } else if (e instanceof QueryException) {