How can I catch exceptions from external processes that are combined with #&& etc.. ?
scala> import scala.sys.process._
scala> try{ "throw " ! }catch{ case e: Exception => }
res1: AnyVal = ()
scala> try{ "throw " #&& "ls" ! }catch{ case e: Exception => }
Exception in thread "Thread-10" java.io.IOException: Cannot run program "throw": error=2, No such file or directory
You already do. Try
The
!just logs the exception to the console, which is a bit confusing when you see it in the REPL, but it does not crash.