PY-81939: Do not show the full log on exec error dialog.

`PyError.message` contains the full log: all `orReturn("some text")` messages.

While they help user sometimes, some of them duplicate otuput and mustn't be displayed two times.

GitOrigin-RevId: 9a726cfcc8cb6b23825adc5d7dd505e1b8afd9c2
This commit is contained in:
Ilya.Kazakevich
2025-06-14 03:05:36 +02:00
committed by intellij-monorepo-bot
parent eb4441210b
commit cd9fd36b44
4 changed files with 10 additions and 4 deletions

View File

@@ -25,7 +25,7 @@ class ExecError(
/**
* optional message to be displayed to the user: Why did we run this process. I.e "running pip to install package".
*/
additionalMessageToUser: @NlsContexts.DialogTitle String? = null,
val additionalMessageToUser: @NlsContexts.DialogTitle String? = null,
) : PyError(getExecErrorMessage(exe.toString(), args, additionalMessageToUser, errorReason)) {
val asCommand: String get() = (arrayOf(exe.toString()) + args).joinToString(" ")
}

View File

@@ -18,7 +18,7 @@ import java.util.concurrent.CopyOnWriteArrayList
*/
sealed class PyError(message: @NlsSafe String) {
private val _messages = CopyOnWriteArrayList<@Nls String>(listOf(message))
val message: @Nls String get() = _messages.reversed().joinToString(": ")
val message: @Nls String get() = _messages.reversed().joinToString("\n")
/**
* To be used by [getOr], see it for more info

View File

@@ -1589,6 +1589,7 @@ package.install.with.options.dialog.title=Package Install with Options
python.toolwindow.packages.collapse.all.action=Collapse All
django.template.language=Template Language
python.error=Error
python.error.full.log=See full error log
action.UvSyncAction.text=uv Sync
action.UvLockAction.text=uv Lock

View File

@@ -57,7 +57,7 @@ fun showProcessExecutionErrorDialog(
) {
check(project == null || !project.isDisposed)
val errorMessageText = execError.message + PyBundle.message("dialog.message.command.could.not.complete")
val errorMessageText = PyBundle.message("dialog.message.command.could.not.complete")
// HTML format for text in `JBLabel` enables text wrapping
val errorMessageLabel = JBLabel(UIUtil.toHtml(errorMessageText), Messages.getErrorIcon(), SwingConstants.LEFT)
@@ -89,12 +89,17 @@ fun showProcessExecutionErrorDialog(
val formBuilder = FormBuilder()
.addComponent(errorMessageLabel)
.addComponent(JButton(PyBundle.message("python.error.full.log")).apply {
addActionListener {
Messages.showErrorDialog(execError.message, PyBundle.message("python.error"))
}
})
.addComponentFillVertically(commandOutputPanel, UIUtil.DEFAULT_VGAP)
object : DialogWrapper(project) {
init {
init()
title = errorMessageText
title = execError.additionalMessageToUser ?: errorMessageText
}
override fun createActions(): Array<Action> = arrayOf(okAction)