Skip to content

Commit 61721f0

Browse files
authored
Merge pull request #2428 from digma-ai/fix-handling-of-exception-for-get-about
better exception handling for methods that should not affect connecti… Closes #2416
2 parents 87e0d39 + b1fec0e commit 61721f0

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

ide-common/src/main/java/org/digma/intellij/plugin/analytics/AnalyticsService.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -638,18 +638,22 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
638638

639639
//this message should help us understand the logs when debugging issues. it will help
640640
// understand that there are more and more exceptions.
641-
//code below and in handleInvocationTargetException will log the exceptions but our Log class
641+
//code below and in ApiErrorHandler.handleInvocationTargetException will log the exceptions but our Log class
642642
// will not explode the logs, so we don't see all the exceptions in the log as they happen.
643643
//this message will explode the idea.log if user has digma trace logging on and no backend running,
644644
// which shouldn't happen, users should not have digma trace logging on all the time.
645-
var realCause = ExceptionUtils.findRootCause(e);
646-
exception = realCause;
647-
Log.log(LOGGER::trace, "got exception in AnalyticsService {}", realCause);
645+
var rootCause = ExceptionUtils.findRootCausePreferConnectionException(e);
646+
exception = rootCause;
647+
Log.log(LOGGER::trace, "got exception in AnalyticsService {}", rootCause);
648648

649649

650+
//for these methods we rethrow the exception without effecting the connection status.
651+
//prefer connection exception as root cause because if the code checks isConnectionException it should be true,
652+
// if we put the real root-cause it may be an exception that is not considered connection exception, for example
653+
// ssl exception may wrap EOFException and EOFException alone is not considered connection exception.
650654
if (methodsThatShouldNotChangeConnectionStatus.contains(method.getName())) {
651655
Log.warnWithException(LOGGER, e, "error in method {}", method.getName());
652-
throw new AnalyticsServiceException(realCause);
656+
throw new AnalyticsServiceException(rootCause);
653657
}
654658

655659

ide-common/src/main/java/org/digma/intellij/plugin/common/ExceptionUtils.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,20 @@ public static Throwable findFirstNonWrapperException(@NotNull Throwable throwabl
5757
}
5858

5959

60+
@NotNull
61+
public static Throwable findRootCausePreferConnectionException(@NotNull Throwable throwable) {
62+
var rootCause = findConnectException(throwable);
63+
if (rootCause == null) {
64+
rootCause = findSslException(throwable);
65+
}
66+
if (rootCause == null) {
67+
rootCause = findRootCause(throwable);
68+
}
69+
return rootCause;
70+
}
71+
72+
73+
6074
@NotNull
6175
public static Throwable findRootCause(@NotNull Throwable throwable) {
6276

0 commit comments

Comments
 (0)