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 5d96f182..97ecebaf 100644 --- a/src/main/kotlin/org/move/cli/runConfigurations/aptos/Aptos.kt +++ b/src/main/kotlin/org/move/cli/runConfigurations/aptos/Aptos.kt @@ -190,11 +190,9 @@ data class Aptos(val cliLocation: Path, val parentDisposable: Disposable?): Disp runner: CapturingProcessHandler.() -> ProcessOutput = { runProcessWithGlobalProgress() } ): AptosProcessResult { val processOutput = executeCommandLine(commandLine, colored, listener, runner) + .ignoreNonZeroExitCode() .unwrapOrElse { - if (it !is RsProcessExecutionException.FailedWithNonZeroExitCode) { - return Err(it) - } - it.output + return Err(it) } val json = processOutput.stdout diff --git a/src/main/kotlin/org/move/openapiext/MvProcessResult.kt b/src/main/kotlin/org/move/openapiext/MvProcessResult.kt index d155a2e1..b39a8cea 100644 --- a/src/main/kotlin/org/move/openapiext/MvProcessResult.kt +++ b/src/main/kotlin/org/move/openapiext/MvProcessResult.kt @@ -12,41 +12,41 @@ import org.move.stdext.RsResult typealias RsProcessResult = RsResult -sealed class RsProcessExecutionOrDeserializationException : RuntimeException { - constructor(cause: Throwable) : super(cause) - constructor(message: String) : super(message) +sealed class RsProcessExecutionOrDeserializationException: RuntimeException { + constructor(cause: Throwable): super(cause) + constructor(message: String): super(message) } -class RsDeserializationException(cause: JacksonException) : +class RsDeserializationException(cause: JacksonException): RsProcessExecutionOrDeserializationException(cause) -sealed class RsProcessExecutionException : RsProcessExecutionOrDeserializationException { - constructor(message: String) : super(message) - constructor(cause: Throwable) : super(cause) +sealed class RsProcessExecutionException: RsProcessExecutionOrDeserializationException { + constructor(message: String): super(message) + constructor(cause: Throwable): super(cause) abstract val commandLineString: String class Start( override val commandLineString: String, cause: ExecutionException, - ) : RsProcessExecutionException(cause) + ): RsProcessExecutionException(cause) class Canceled( override val commandLineString: String, val output: ProcessOutput, message: String = errorMessage(commandLineString, output), - ) : RsProcessExecutionException(message) + ): RsProcessExecutionException(message) class Timeout( override val commandLineString: String, val output: ProcessOutput, - ) : RsProcessExecutionException(errorMessage(commandLineString, output)) + ): RsProcessExecutionException(errorMessage(commandLineString, output)) /** The process exited with non-zero exit code */ class FailedWithNonZeroExitCode( override val commandLineString: String, val output: ProcessOutput, - ) : RsProcessExecutionException(errorMessage(commandLineString, output)) + ): RsProcessExecutionException(errorMessage(commandLineString, output)) companion object { fun errorMessage(commandLineString: String, output: ProcessOutput): String = """ @@ -68,3 +68,12 @@ fun RsProcessResult.ignoreExitCode(): RsResult RsResult.Ok(err.output) } } + +fun RsProcessResult.ignoreNonZeroExitCode(): RsResult = + when (this) { + is RsResult.Ok -> this + is RsResult.Err -> when (err) { + is RsProcessExecutionException.FailedWithNonZeroExitCode -> RsResult.Ok(err.output) + else -> this + } + }