如何捕获与#&&等相结合的外部进程的异常。?
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发布于 2012-09-03 20:29:14
你已经这么做了。试一试
try {
val x = "throw" #&& "ls" !
} catch {
case x => println("caught")
}!只是将异常记录到控制台,当您在REPL中看到它时,这有点令人困惑,但它不会崩溃。
https://stackoverflow.com/questions/12244822
复制相似问题