From 34d552cdcfff86c5157494cd765f081b443ded3f Mon Sep 17 00:00:00 2001 From: Maksim Verkoshanskii <48138666+ellizio@users.noreply.github.com> Date: Mon, 8 Apr 2024 12:01:51 +0300 Subject: [PATCH 1/3] Update README.md --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 401d57c..6b2b845 100644 --- a/README.md +++ b/README.md @@ -23,9 +23,13 @@ Rider plugin to generate OData Reference using OData CLI ## ⚠️ Known Restrictions -TODO +1. Output metadata .xml file is always named `OData ServiceCsdl.xml` which will throw a runtime exception. See more [https://github.com/OData/ODataConnectedService/issues/384](https://github.com/OData/ODataConnectedService/issues/384)\ +There is a workaround:\ +a. Rename `OData ServiceCsdl.xml` to `Csdl.xml`, where `` is value from OData CLI UI dialog\ +b. Adjust embedded resource path in `.csproj` file\ +c. Find `GeneratedEdmModel.filePath` constant in `Reference.cs` and change value from `OData ServiceCsdl.xml` to `Csdl.xml`, where `` is value from OData CLI UI dialog ## Additional References - [Changelog](https://github.com/ellizio/rider--plugin--odata-cli-ui/blob/master/CHANGELOG.md) -- [OData CLI](https://learn.microsoft.com/en-us/odata/odatacli/getting-started) \ No newline at end of file +- [OData CLI](https://learn.microsoft.com/en-us/odata/odatacli/getting-started) From 587242c488d2cd0ab3b5bcf19c53db1e9afc607e Mon Sep 17 00:00:00 2001 From: Maksim Verkoshanskii <48138666+ellizio@users.noreply.github.com> Date: Mon, 8 Apr 2024 12:02:53 +0300 Subject: [PATCH 2/3] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6b2b845..ec385e8 100644 --- a/README.md +++ b/README.md @@ -25,9 +25,9 @@ Rider plugin to generate OData Reference using OData CLI 1. Output metadata .xml file is always named `OData ServiceCsdl.xml` which will throw a runtime exception. See more [https://github.com/OData/ODataConnectedService/issues/384](https://github.com/OData/ODataConnectedService/issues/384)\ There is a workaround:\ -a. Rename `OData ServiceCsdl.xml` to `Csdl.xml`, where `` is value from OData CLI UI dialog\ -b. Adjust embedded resource path in `.csproj` file\ -c. Find `GeneratedEdmModel.filePath` constant in `Reference.cs` and change value from `OData ServiceCsdl.xml` to `Csdl.xml`, where `` is value from OData CLI UI dialog +`a.` Rename `OData ServiceCsdl.xml` to `Csdl.xml`, where `` is value from OData CLI UI dialog\ +`b.` Adjust embedded resource path in `.csproj` file\ +`c.` Find `GeneratedEdmModel.filePath` constant in `Reference.cs` and change value from `OData ServiceCsdl.xml` to `Csdl.xml`, where `` is value from OData CLI UI dialog ## Additional References From 14ba8e4fec131c1f1d793d8198c80e4a12c5920f Mon Sep 17 00:00:00 2001 From: ellizio Date: Mon, 8 Apr 2024 18:12:40 +0300 Subject: [PATCH 3/3] exception handling --- .../odatacliui/actions/OpenCliDialogAction.kt | 14 +++++++++++--- .../ellizio/odatacliui/extensions/ConsoleViewEx.kt | 11 +++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 src/rider/main/kotlin/ru/ellizio/odatacliui/extensions/ConsoleViewEx.kt diff --git a/src/rider/main/kotlin/ru/ellizio/odatacliui/actions/OpenCliDialogAction.kt b/src/rider/main/kotlin/ru/ellizio/odatacliui/actions/OpenCliDialogAction.kt index 5c009a4..dcb7336 100644 --- a/src/rider/main/kotlin/ru/ellizio/odatacliui/actions/OpenCliDialogAction.kt +++ b/src/rider/main/kotlin/ru/ellizio/odatacliui/actions/OpenCliDialogAction.kt @@ -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 @@ -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())) diff --git a/src/rider/main/kotlin/ru/ellizio/odatacliui/extensions/ConsoleViewEx.kt b/src/rider/main/kotlin/ru/ellizio/odatacliui/extensions/ConsoleViewEx.kt new file mode 100644 index 0000000..bf6d6af --- /dev/null +++ b/src/rider/main/kotlin/ru/ellizio/odatacliui/extensions/ConsoleViewEx.kt @@ -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) +} \ No newline at end of file