Skip to content

Commit

Permalink
Ignore some errors for real this time
Browse files Browse the repository at this point in the history
  • Loading branch information
RedNesto committed Aug 24, 2021
1 parent 3ea6fc8 commit 7df2a6c
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/main/kotlin/errorreporter/ErrorReporter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ import com.intellij.openapi.diagnostic.ErrorReportSubmitter
import com.intellij.openapi.diagnostic.IdeaLoggingEvent
import com.intellij.openapi.diagnostic.SubmittedReportInfo
import com.intellij.openapi.progress.EmptyProgressIndicator
import com.intellij.openapi.progress.ProgressIndicator
import com.intellij.openapi.progress.ProgressManager
import com.intellij.openapi.progress.Task
import com.intellij.util.Consumer
import java.awt.Component

Expand All @@ -42,14 +44,26 @@ class ErrorReporter : ErrorReportSubmitter() {
parentComponent: Component,
consumer: Consumer<in SubmittedReportInfo>
): Boolean {
val dataContext = DataManager.getInstance().getDataContext(parentComponent)
val project = CommonDataKeys.PROJECT.getData(dataContext)

val event = events[0]
val errorMessage = event.throwable.message
if (errorMessage != null && ignoredErrorMessages.any(errorMessage::contains)) {
val errorMessage = event.throwableText
if (errorMessage.isNotBlank() && ignoredErrorMessages.any(errorMessage::contains)) {
val task = object : Task.Backgroundable(project, "Ignored error") {
override fun run(indicator: ProgressIndicator) {
consumer.consume(SubmittedReportInfo(null, null, SubmittedReportInfo.SubmissionStatus.DUPLICATE))
}
}
if (project == null) {
task.run(EmptyProgressIndicator())
} else {
ProgressManager.getInstance().run(task)
}
return true
}

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

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

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

val project = CommonDataKeys.PROJECT.getData(dataContext)

val task = AnonymousFeedbackTask(
project,
"Submitting error report",
Expand Down

0 comments on commit 7df2a6c

Please sign in to comment.