Skip to content

Commit 7df2a6c

Browse files
committed
Ignore some errors for real this time
1 parent 3ea6fc8 commit 7df2a6c

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/main/kotlin/errorreporter/ErrorReporter.kt

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ import com.intellij.openapi.diagnostic.ErrorReportSubmitter
2424
import com.intellij.openapi.diagnostic.IdeaLoggingEvent
2525
import com.intellij.openapi.diagnostic.SubmittedReportInfo
2626
import com.intellij.openapi.progress.EmptyProgressIndicator
27+
import com.intellij.openapi.progress.ProgressIndicator
2728
import com.intellij.openapi.progress.ProgressManager
29+
import com.intellij.openapi.progress.Task
2830
import com.intellij.util.Consumer
2931
import java.awt.Component
3032

@@ -42,14 +44,26 @@ class ErrorReporter : ErrorReportSubmitter() {
4244
parentComponent: Component,
4345
consumer: Consumer<in SubmittedReportInfo>
4446
): Boolean {
47+
val dataContext = DataManager.getInstance().getDataContext(parentComponent)
48+
val project = CommonDataKeys.PROJECT.getData(dataContext)
49+
4550
val event = events[0]
46-
val errorMessage = event.throwable.message
47-
if (errorMessage != null && ignoredErrorMessages.any(errorMessage::contains)) {
51+
val errorMessage = event.throwableText
52+
if (errorMessage.isNotBlank() && ignoredErrorMessages.any(errorMessage::contains)) {
53+
val task = object : Task.Backgroundable(project, "Ignored error") {
54+
override fun run(indicator: ProgressIndicator) {
55+
consumer.consume(SubmittedReportInfo(null, null, SubmittedReportInfo.SubmissionStatus.DUPLICATE))
56+
}
57+
}
58+
if (project == null) {
59+
task.run(EmptyProgressIndicator())
60+
} else {
61+
ProgressManager.getInstance().run(task)
62+
}
4863
return true
4964
}
5065

5166
val errorData = ErrorData(event.throwable, IdeaLogger.ourLastActionId)
52-
val dataContext = DataManager.getInstance().getDataContext(parentComponent)
5367

5468
errorData.description = additionalInfo
5569
errorData.message = event.message
@@ -68,8 +82,6 @@ class ErrorReporter : ErrorReportSubmitter() {
6882

6983
val (reportValues, attachments) = errorData.formatErrorData()
7084

71-
val project = CommonDataKeys.PROJECT.getData(dataContext)
72-
7385
val task = AnonymousFeedbackTask(
7486
project,
7587
"Submitting error report",

0 commit comments

Comments
 (0)