From da5c71fd9f116e8f3a01441229a6d05acb9f2c2d Mon Sep 17 00:00:00 2001 From: Kamil Kloch Date: Thu, 3 Aug 2023 09:33:33 +0200 Subject: [PATCH 1/3] Update `reportFailure` scaladoc - add explanation of an unhandled error. h/t @armanbilge https://github.com/typelevel/cats-effect/issues/3768 --- .../src/main/scala/cats/effect/IOApp.scala | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/core/jvm/src/main/scala/cats/effect/IOApp.scala b/core/jvm/src/main/scala/cats/effect/IOApp.scala index 6f1a0857af..c63b6a3585 100644 --- a/core/jvm/src/main/scala/cats/effect/IOApp.scala +++ b/core/jvm/src/main/scala/cats/effect/IOApp.scala @@ -230,11 +230,25 @@ trait IOApp { ) /** - * Configures the action to perform when unhandled errors are caught by the runtime. By - * default, this simply delegates to [[cats.effect.std.Console!.printStackTrace]]. It is safe - * to perform any `IO` action within this handler; it will not block the progress of the - * runtime. With that said, some care should be taken to avoid raising unhandled errors as a - * result of handling unhandled errors, since that will result in the obvious chaos. + * Configures the action to perform when unhandled errors are caught by the runtime. An + * unhandled error is an error that is raised on a Fiber that nobody is joining. + * + * For example: + * + * {{{ + * import scala.concurrent.duration._ + * override def run: IO[Unit] = IO(throw new Exception("")).start *> IO.sleep(1.second) + * }}} + * + * In this case, the exception is raised on a Fiber with no listeners. So nobody would be + * notified about that error. Therefore it is unhandled, and it goes through the reportFailure + * mechanism. + * + * By default, `reportFailure` simply delegates to + * [[cats.effect.std.Console!.printStackTrace]]. It is safe to perform any `IO` action within + * this handler; it will not block the progress of the runtime. With that said, some care + * should be taken to avoid raising unhandled errors as a result of handling unhandled errors, + * since that will result in the obvious chaos. */ protected def reportFailure(err: Throwable): IO[Unit] = Console[IO].printStackTrace(err) From 7e4bcbb9e1d94c63dad8adf4643a6ecc649f0484 Mon Sep 17 00:00:00 2001 From: Kamil Kloch Date: Mon, 7 Aug 2023 11:21:29 +0200 Subject: [PATCH 2/3] Update scaladoc. --- core/jvm/src/main/scala/cats/effect/IOApp.scala | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/core/jvm/src/main/scala/cats/effect/IOApp.scala b/core/jvm/src/main/scala/cats/effect/IOApp.scala index c63b6a3585..d512280972 100644 --- a/core/jvm/src/main/scala/cats/effect/IOApp.scala +++ b/core/jvm/src/main/scala/cats/effect/IOApp.scala @@ -230,8 +230,8 @@ trait IOApp { ) /** - * Configures the action to perform when unhandled errors are caught by the runtime. An - * unhandled error is an error that is raised on a Fiber that nobody is joining. + * Configures the action to perform when unhandled errors are caught by the runtime. + * An unhandled error is an error that is raised (and not handled) on a Fiber that nobody is joining. * * For example: * @@ -240,9 +240,8 @@ trait IOApp { * override def run: IO[Unit] = IO(throw new Exception("")).start *> IO.sleep(1.second) * }}} * - * In this case, the exception is raised on a Fiber with no listeners. So nobody would be - * notified about that error. Therefore it is unhandled, and it goes through the reportFailure - * mechanism. + * In this case, the exception is raised on a Fiber with no listeners. Nobody would be notified + * about that error. Therefore it is unhandled, and it goes through the reportFailure mechanism. * * By default, `reportFailure` simply delegates to * [[cats.effect.std.Console!.printStackTrace]]. It is safe to perform any `IO` action within From 492fbd1c04aa50366569b257b196cb4002e88d80 Mon Sep 17 00:00:00 2001 From: Kamil Kloch Date: Mon, 7 Aug 2023 11:34:42 +0200 Subject: [PATCH 3/3] scalafmt. --- core/jvm/src/main/scala/cats/effect/IOApp.scala | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/core/jvm/src/main/scala/cats/effect/IOApp.scala b/core/jvm/src/main/scala/cats/effect/IOApp.scala index d512280972..0557102baa 100644 --- a/core/jvm/src/main/scala/cats/effect/IOApp.scala +++ b/core/jvm/src/main/scala/cats/effect/IOApp.scala @@ -230,8 +230,9 @@ trait IOApp { ) /** - * Configures the action to perform when unhandled errors are caught by the runtime. - * An unhandled error is an error that is raised (and not handled) on a Fiber that nobody is joining. + * Configures the action to perform when unhandled errors are caught by the runtime. An + * unhandled error is an error that is raised (and not handled) on a Fiber that nobody is + * joining. * * For example: * @@ -240,8 +241,9 @@ trait IOApp { * override def run: IO[Unit] = IO(throw new Exception("")).start *> IO.sleep(1.second) * }}} * - * In this case, the exception is raised on a Fiber with no listeners. Nobody would be notified - * about that error. Therefore it is unhandled, and it goes through the reportFailure mechanism. + * In this case, the exception is raised on a Fiber with no listeners. Nobody would be + * notified about that error. Therefore it is unhandled, and it goes through the reportFailure + * mechanism. * * By default, `reportFailure` simply delegates to * [[cats.effect.std.Console!.printStackTrace]]. It is safe to perform any `IO` action within