I haven't been able to find a way to provide an empty (no op) way to complete a catch block in the following Scala code:
var autoCloseables: List[AutoCloseable] = List()
... //some code that fills the list with various java.sql.* instances; Connection, Statement, ResultSet
autoCloseables.map(try {_.close} catch {case se: SQLException => NoOp} )
I have tried to replace "NoOp" with "()", "Unit", "None", "se.getMessage()", etc. I continue to receive an error in Eclipse stating various forms of "type mismatch; found : Unit, required: AutoCloseable => ?".
I have also tried changing the final line to the below, but still receive the same warning as above:
autoCloseables.map(try {_.close} catch {case _: Throwable => } )
Any specific guidance on this would be greatly appreciated. And, I know about the ARM library. For now, please assume I am unable to use it and need a resolution framed from this particular problem formation. Thank you.
import scala.util.Try
autoCloseables.map(a => Try(a.close))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With