Skip to content

Commit

Permalink
exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ellizio committed Apr 8, 2024
1 parent e2eea47 commit 14ba8e4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import com.jetbrains.rider.projectView.actions.isProjectModelReady
import com.jetbrains.rider.projectView.solution
import com.jetbrains.rider.projectView.workspace.isProject
import com.jetbrains.rider.projectView.workspace.isWebReferenceFolder
import ru.ellizio.odatacliui.extensions.printCommandError
import ru.ellizio.odatacliui.models.ActionMetadata
import ru.ellizio.odatacliui.terminal.executors.CommandLineExecutor

Expand Down Expand Up @@ -61,10 +62,17 @@ class OpenCliDialogAction : AnAction() {
consoleView = CliToolWindowManager.getInstance(project).instantiateConsole()
}

val odataCliExecutor = CommandLineExecutor(project, model.buildODataCliCommand(), consoleView!!)
val success = odataCliExecutor.execute()
if (!success)
val odataCliCommand = model.buildODataCliCommand()
try {
val odataCliExecutor = CommandLineExecutor(project, odataCliCommand, consoleView!!)
val success = odataCliExecutor.execute()
if (!success)
return
}
catch (t: Throwable) {
consoleView!!.printCommandError(t, odataCliCommand.commandLineString)
return
}

project.lifetime.launchOnUi {
project.solution.protocolModel.addEmbeddedResource.startSuspending(project.lifetime, EmbeddedResourceDefinition(metadata.projectName, model.getCsdlPath()))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package ru.ellizio.odatacliui.extensions

import com.intellij.execution.ui.ConsoleView
import com.intellij.execution.ui.ConsoleViewContentType

fun ConsoleView.printCommandError(t: Throwable, command: String) {
print("Error attempting to call command ", ConsoleViewContentType.LOG_ERROR_OUTPUT)
print(command, ConsoleViewContentType.LOG_INFO_OUTPUT)
print(":${System.lineSeparator()}", ConsoleViewContentType.LOG_ERROR_OUTPUT)
print(t.localizedMessage, ConsoleViewContentType.ERROR_OUTPUT)
}

0 comments on commit 14ba8e4

Please sign in to comment.