Can anyone explain me what is happening with this code? There is no database running because the idea is to catch the exception.
val col = MongoConnection("localhost")("myDB")("myCol")
// Using Try to catch any exception but there is NO exception
// ex1
val ex1 = Try{col.find()}
// Using Try to catch any exception, now we have an exception
// ex2
val ex2 = Try{col.findOne()}
When executing ex2 the exception is caught by Try so
ex2: scala.util.Try[Option[a.T]] = Failure(com.mongodb.MongoException$Network: Read operation to server localhost/127.0.0.1:27017 failed on database myDB)
Why in the ex1 example cant the exception be caught (ex1 doesnt exists after running that code)?
EDIT
Seems that:
val ex1 = Try {col.find().toList}
puts the exception inside the Try into ex1