From 6b3f3ce8ec65e697f91897d9bade53b0047c3074 Mon Sep 17 00:00:00 2001 From: Maksim Kurnikov Date: Sun, 10 Nov 2024 14:35:31 +0100 Subject: [PATCH] handle jackson exception --- .../org/move/cli/runConfigurations/aptos/Aptos.kt | 11 +++++++---- .../cli/runConfigurations/aptos/AptosProcessOutput.kt | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/org/move/cli/runConfigurations/aptos/Aptos.kt b/src/main/kotlin/org/move/cli/runConfigurations/aptos/Aptos.kt index e58671fd..cad13d8c 100644 --- a/src/main/kotlin/org/move/cli/runConfigurations/aptos/Aptos.kt +++ b/src/main/kotlin/org/move/cli/runConfigurations/aptos/Aptos.kt @@ -1,5 +1,6 @@ package org.move.cli.runConfigurations.aptos +import com.fasterxml.jackson.core.JacksonException import com.intellij.execution.configuration.EnvironmentVariablesData import com.intellij.execution.process.CapturingProcessHandler import com.intellij.execution.process.ProcessListener @@ -72,9 +73,7 @@ data class Aptos(val cliLocation: Path, val parentDisposable: Disposable?): Disp ), workingDirectory = projectDir ) - val aptosProcessOutput = - executeAptosCommandLine(commandLine, colored = true, listener = processListener) - return aptosProcessOutput + return executeAptosCommandLine(commandLine, colored = true, listener = processListener) } fun checkProject(args: AptosCompileArgs): RsResult { @@ -203,7 +202,11 @@ data class Aptos(val cliLocation: Path, val parentDisposable: Disposable?): Disp val json = processOutput.stdout .lines().dropWhile { l -> !l.startsWith("{") }.joinToString("\n").trim() - val exitStatus = AptosExitStatus.fromJson(json) + val exitStatus = try { + AptosExitStatus.fromJson(json) + } catch (e: JacksonException) { + return Err(RsDeserializationException(e)) + } val aptosProcessOutput = AptosProcessOutput(Unit, processOutput, exitStatus) return Ok(aptosProcessOutput) diff --git a/src/main/kotlin/org/move/cli/runConfigurations/aptos/AptosProcessOutput.kt b/src/main/kotlin/org/move/cli/runConfigurations/aptos/AptosProcessOutput.kt index 9c4cd0af..d26204c4 100644 --- a/src/main/kotlin/org/move/cli/runConfigurations/aptos/AptosProcessOutput.kt +++ b/src/main/kotlin/org/move/cli/runConfigurations/aptos/AptosProcessOutput.kt @@ -1,10 +1,10 @@ package org.move.cli.runConfigurations.aptos import com.intellij.execution.process.ProcessOutput -import org.move.openapiext.RsProcessExecutionException +import org.move.openapiext.RsProcessExecutionOrDeserializationException import org.move.stdext.RsResult -typealias AptosProcessResult = RsResult, RsProcessExecutionException> +typealias AptosProcessResult = RsResult, RsProcessExecutionOrDeserializationException> data class AptosProcessOutput( val item: T,