---
title: "Comment by sammo90 on \"Error Handling in Cats Effect [Part-9]\" | Hashnode"
description: "// deprecated: method onError in class IO is deprecated since 3.6.0: Use onError with PartialFunction argument: val loggedFailedError: IO[Int] = failedIO.onErro"
url: "https://hashnode.com/posts/error-handling-in-cats-effect-part-9/64452d9126baa38eee9138f2/comment/6a003fc2e3eebc2e20505ac5"
---

[Discussion](https://hashnode.com/posts/error-handling-in-cats-effect-part-9/64452d9126baa38eee9138f2)

Comment [Error Handling in Cats Effect \[Part-9\]](https://hashnode.com/posts/error-handling-in-cats-effect-part-9/64452d9126baa38eee9138f2)

[sammo90](https://hashnode.com/@sammo90)

[May 10](https://hashnode.com/posts/error-handling-in-cats-effect-part-9/64452d9126baa38eee9138f2/comment/6a003fc2e3eebc2e20505ac5)

// deprecated: method onError in class IO is deprecated since 3.6.0: Use onError with PartialFunction argument:

```
val loggedFailedError: 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}")}
```

[Yadukrishnan](https://hashnode.com/@yadukrishnan)

[May 15](https://hashnode.com/posts/error-handling-in-cats-effect-part-9/64452d9126baa38eee9138f2/comment/6a003fc2e3eebc2e20505ac5#reply-6a072f1673afc88757763321)

Hey [sammo90](https://hashnode.com/@sammo90 "sammo90") , are you using the version 3.6.0 ? This deprecation warning has been removed from 3.6.1. I think it was due to some package visibility issue.

[sammo90](https://hashnode.com/@sammo90)

[May 15](https://hashnode.com/posts/error-handling-in-cats-effect-part-9/64452d9126baa38eee9138f2/comment/6a003fc2e3eebc2e20505ac5#reply-6a0737d673afc887577d3396)

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}")}
```
