Using Scala 3.8.3 (Windows 10):
I get the warning:
Compiling project (Scala 3.8.3, JVM (temurin:21))
[warn] .\yadu9.sc:51:38
[warn] method onError in class IO is deprecated since 3.6.0: Use onError with PartialFunction argument
[warn] val loggedFailedError_1: IO[Int] = failedIO.onError(ex => IO.println("It failed with message: "+ex.getMessage))
[warn] ^^^^^^^^^^^^^^^^
Compiled project (Scala 3.8.3, JVM (temurin:21))
[io-compute-1] 500
[io-compute-blocker-1] -2
[io-compute-2] -2
[io-compute-blocker-1] 0
[io-compute-blocker-1] 0
[io-compute-blocker-1] -9
It failed with message: Boom!
Exception in thread "main" java.lang.RuntimeException: Boom!
...
Code section is:
val errorIO = IO(100/0)
val recoveredFailedIO_1: IO[Int] = errorIO.recover {
case ex: ArithmeticException => -9
}
// deprecated: method onError in class IO is deprecated since 3.6.0: Use onError with PartialFunction argument
val loggedFailedError_1: IO[Int] = failedIO.onError(ex => IO.println("It failed with message: "+ex.getMessage))
// new:
val loggedFailedError: IO[Int] =
failedIO.onError {case ex => IO.println(s"It failed with message: ${ex.getMessage}")}