Skip to content

Commit

Permalink
handle jackson exception
Browse files Browse the repository at this point in the history
  • Loading branch information
mkurnikov committed Nov 10, 2024
1 parent 4218965 commit 6b3f3ce
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 7 additions & 4 deletions src/main/kotlin/org/move/cli/runConfigurations/aptos/Aptos.kt
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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<ProcessOutput, RsProcessExecutionException.Start> {
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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<T> = RsResult<AptosProcessOutput<T>, RsProcessExecutionException>
typealias AptosProcessResult<T> = RsResult<AptosProcessOutput<T>, RsProcessExecutionOrDeserializationException>

data class AptosProcessOutput<T>(
val item: T,
Expand Down

0 comments on commit 6b3f3ce

Please sign in to comment.