Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.utbot.intellij.plugin.error

import com.intellij.openapi.application.invokeLater
import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.Messages

fun showErrorDialogLater(project: Project, message: String, title: String) {
invokeLater {
Messages.showErrorDialog(project, message, title)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import org.jetbrains.kotlin.psi.KtPsiFactory
import org.jetbrains.kotlin.psi.psiUtil.endOffset
import org.jetbrains.kotlin.psi.psiUtil.startOffset
import org.jetbrains.kotlin.scripting.resolve.classId
import org.utbot.intellij.plugin.error.showErrorDialogLater

object TestGenerator {
fun generateTests(model: GenerateTestsModel, testCases: Map<PsiClass, List<UtTestCase>>) {
Expand Down Expand Up @@ -268,7 +269,11 @@ object TestGenerator {
SarifReportIdea.createAndSave(model, testCases, generatedTestsCode, sourceFinding)
}
} catch (e: Exception) {
logger.error{ "Cannot save Sarif report via generated tests: error occurred '${e.message}'"}
showErrorDialogLater(
project,
message = "Cannot save Sarif report via generated tests: error occurred '${e.message}'",
title = "Failed to save Sarif report"
)
}

try {
Expand All @@ -280,7 +285,11 @@ object TestGenerator {
}
}
} catch (e: Exception) {
logger.error { "Cannot save tests generation report: error occurred '${e.message}'" }
showErrorDialogLater(
project,
message = "Cannot save tests generation report: error occurred '${e.message}'",
title = "Failed to save tests report"
)
}
}

Expand Down Expand Up @@ -393,6 +402,10 @@ object TestGenerator {
}

private fun showCreatingClassError(project: Project, testClassName: String) {
logger.error { "Cannot Create Class '$testClassName'" }
showErrorDialogLater(
project,
message = "Cannot Create Class '$testClassName'",
title = "Failed to Create Class"
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import java.nio.file.Paths
import java.util.concurrent.TimeUnit
import mu.KotlinLogging
import org.jetbrains.kotlin.idea.util.module
import org.utbot.intellij.plugin.error.showErrorDialogLater

object UtTestsDialogProcessor {

Expand Down Expand Up @@ -165,7 +166,11 @@ object UtTestsDialogProcessor {
}

if (notEmptyCases.isEmpty()) {
logger.error { "Failed to generate unit tests for class $className" }
showErrorDialogLater(
model.project,
errorMessage(className, secondsTimeout),
title = "Failed to generate unit tests for class $className"
)
} else {
testCasesByClass[srcClass] = notEmptyCases
}
Expand Down