All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.joern.swiftsrc2cpg.utils.ExternalCommand.scala Maven / Gradle / Ivy

There is a newer version: 4.0.78
Show newest version
package io.joern.swiftsrc2cpg.utils

import scala.util.Failure
import scala.util.Success
import scala.util.Try

object ExternalCommand extends io.joern.x2cpg.utils.ExternalCommand {

  override def handleRunResult(result: Try[Int], stdOut: Seq[String], stdErr: Seq[String]): Try[Seq[String]] = {
    result match {
      case Success(0) =>
        Success(stdOut)
      case Success(_) if stdErr.isEmpty && stdOut.nonEmpty =>
        // SwiftAstGen exits with exit code != 0 on Windows.
        // To catch with we specifically handle the empty stdErr here.
        Success(stdOut)
      case _ =>
        val allOutput = stdOut ++ stdErr
        Failure(new RuntimeException(allOutput.mkString(System.lineSeparator())))
    }
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy