Skip to content

Commit 1b73e14

Browse files
authored
Disable telemetry for user error. (#213)
* should not record user errors to application insight. * use isUserError to test whether a exception is a user error. * ensure a cleaner code
1 parent c3b0201 commit 1b73e14

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

com.microsoft.java.debug.plugin/src/main/java/com/microsoft/java/debug/plugin/internal/UsageDataLogHandler.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import java.util.logging.Level;
1717
import java.util.logging.LogRecord;
1818

19+
import com.microsoft.java.debug.core.DebugException;
1920
import com.microsoft.java.debug.core.UsageDataSession;
2021
import com.microsoft.java.debug.core.UsageDataStore;
2122

@@ -30,7 +31,9 @@ public UsageDataLogHandler(Level level) {
3031
public void publish(LogRecord record) {
3132
if (record.getLevel().intValue() >= thresholdLevel.intValue()) {
3233
if (record.getThrown() != null) {
33-
// error message
34+
if (isUserError(record.getThrown())) {
35+
return;
36+
}
3437
UsageDataStore.getInstance().logErrorData(record.getMessage(), record.getThrown());
3538
UsageDataSession.enableJdiEventSequence();
3639
} else if (record.getParameters() != null) {
@@ -54,4 +57,7 @@ public void close() throws SecurityException {
5457
// do nothing
5558
}
5659

60+
private static boolean isUserError(Throwable th) {
61+
return th instanceof DebugException && ((DebugException) th).isUserError();
62+
}
5763
}

0 commit comments

Comments
 (0)