mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IJPL-233509 [platform] simpler marking for auto-submitted reports
...; pointless coroutine nesting in `ITNReporter` GitOrigin-RevId: c453b73742235a3c14c48b8bfaee57602b116246
This commit is contained in:
committed by
intellij-monorepo-bot
parent
9f44680311
commit
5f6738063e
@@ -11,8 +11,6 @@ import com.intellij.ide.util.PropertiesComponent
|
||||
import com.intellij.idea.AppMode
|
||||
import com.intellij.internal.statistic.utils.getPluginInfoByDescriptor
|
||||
import com.intellij.openapi.application.impl.ApplicationInfoImpl
|
||||
import com.intellij.openapi.diagnostic.Attachment
|
||||
import com.intellij.openapi.diagnostic.IdeaLoggingEvent
|
||||
import com.intellij.openapi.diagnostic.thisLogger
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.startup.ProjectActivity
|
||||
@@ -90,27 +88,7 @@ object ExceptionAutoReportUtil {
|
||||
return Pair(submitter, plugin)
|
||||
}
|
||||
|
||||
private fun isDefaultSubmitter(submitter: ITNReporter): Boolean {
|
||||
return submitter.javaClass == ITNReporter::class.java
|
||||
}
|
||||
|
||||
private interface PlatformAutoReportedExceptionMarker
|
||||
|
||||
/**
|
||||
* Used to distinguish exceptions from the platform reported by [ITNReporter].
|
||||
* Don't mix with other product-level auto-report systems.
|
||||
*/
|
||||
fun createPlatformAutoReportedEvent(
|
||||
message: String?,
|
||||
throwable: Throwable,
|
||||
attachments: List<Attachment>,
|
||||
plugin: IdeaPluginDescriptor?,
|
||||
data: Any?,
|
||||
): IdeaLoggingEvent {
|
||||
return object : IdeaLoggingEvent(message, throwable, attachments, plugin, data), PlatformAutoReportedExceptionMarker {}
|
||||
}
|
||||
|
||||
fun isPlatformAutoReportedEvent(event: IdeaLoggingEvent): Boolean = event is PlatformAutoReportedExceptionMarker
|
||||
private fun isDefaultSubmitter(submitter: ITNReporter): Boolean = submitter.javaClass == ITNReporter::class.java
|
||||
}
|
||||
|
||||
internal class ReporterIdForEAAutoReporters : AboutPopupDescriptionProvider {
|
||||
|
||||
@@ -24,7 +24,6 @@ import com.intellij.platform.ide.progress.withBackgroundProgress
|
||||
import com.intellij.util.Consumer
|
||||
import kotlinx.coroutines.CancellationException
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
@@ -57,23 +56,21 @@ open class ITNReporter internal constructor(private val postUrl: String) : Error
|
||||
parentComponent: Component,
|
||||
consumer: Consumer<in SubmittedReportInfo>
|
||||
): Boolean {
|
||||
val errorBean = createReportBean(events[0], additionalInfo)
|
||||
val errorBean = createReportBean(events[0], additionalInfo, autoReported = false)
|
||||
val project = CommonDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(parentComponent))
|
||||
return submit(project, errorBean, parentComponent, consumer::consume)
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
suspend fun submitAutomated(event: IdeaLoggingEvent): SubmittedReportInfo {
|
||||
val errorBean = createReportBean(event, comment = "Automatically reported exception")
|
||||
return service<ITNProxyCoroutineScopeHolder>().coroutineScope.async {
|
||||
try {
|
||||
val reportId = ITNProxy.sendError(errorBean, postUrl)
|
||||
SubmittedReportInfo(ITNProxy.getBrowseUrl(reportId), reportId.toString(), SubmittedReportInfo.SubmissionStatus.NEW_ISSUE)
|
||||
}
|
||||
catch (_: Exception) {
|
||||
SubmittedReportInfo(SubmittedReportInfo.SubmissionStatus.FAILED)
|
||||
}
|
||||
}.await()
|
||||
val errorBean = createReportBean(event, comment = "Automatically reported exception", autoReported = true)
|
||||
return try {
|
||||
val reportId = ITNProxy.sendError(errorBean, postUrl)
|
||||
SubmittedReportInfo(ITNProxy.getBrowseUrl(reportId), reportId.toString(), SubmittedReportInfo.SubmissionStatus.NEW_ISSUE)
|
||||
}
|
||||
catch (_: Exception) {
|
||||
SubmittedReportInfo(SubmittedReportInfo.SubmissionStatus.FAILED)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,11 +78,10 @@ open class ITNReporter internal constructor(private val postUrl: String) : Error
|
||||
*/
|
||||
open fun showErrorInRelease(event: IdeaLoggingEvent): Boolean = false
|
||||
|
||||
private fun createReportBean(event: IdeaLoggingEvent, comment: String?): ErrorBean =
|
||||
ErrorBean(event, comment,
|
||||
event.plugin?.pluginId?.idString, event.plugin?.name, event.plugin?.version,
|
||||
IdeaLogger.ourLastActionId,
|
||||
ExceptionAutoReportUtil.isPlatformAutoReportedEvent(event))
|
||||
private fun createReportBean(event: IdeaLoggingEvent, comment: String?, autoReported: Boolean) = ErrorBean(
|
||||
event, comment, event.plugin?.pluginId?.idString, event.plugin?.name, event.plugin?.version,
|
||||
IdeaLogger.ourLastActionId, autoReported
|
||||
)
|
||||
|
||||
private fun submit(
|
||||
project: Project?,
|
||||
|
||||
Reference in New Issue
Block a user