Skip to content

Commit

Permalink
refactor: better fault handling
Browse files Browse the repository at this point in the history
  • Loading branch information
berezovskyi committed Dec 31, 2024
1 parent 36ff8c4 commit 5a62cb2
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions backend/src/main/java/sparqles/utils/FaultDiagnostic.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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) {
Expand Down

0 comments on commit 5a62cb2

Please sign in to comment.